Sub a string value (VB.net) : String « Language Basics « ASP.Net






Sub a string value (VB.net)

<%@ Page Language="VB" %>
<script runat="server">
    
    Sub Button1_Click(sender As Object, e As EventArgs)
      Dim fullString, subString As String
      Dim startPos, length As Integer
    
      startPos = CInt(TextBox2.Text)
      length = CInt(TextBox3.Text)
    
      fullString = TextBox1.Text
      subString = fullString.SubString(startPos, length)
      Label1.Text = subString
    End Sub

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
            <asp:TextBox id="TextBox1" runat="server" TextMode="MultiLine" Width="259px" Height="112px"></asp:TextBox>
        </p>
        <p>
            start: 
            <asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
        </p>
        <p>
            length: 
            <asp:TextBox id="TextBox3" runat="server"></asp:TextBox>
        </p>
        <p>
            <asp:Label id="Label1" runat="server">Label</asp:Label>
        </p>
        <p>
            <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Show Substring"></asp:Button>
        </p>
    </form>
</body>
</html>

           
       








Related examples in the same category

1.String format (C#)
2.Convert String to int and decimal (C#)
3.String concatenation (C#)