Convert value from asp:TextBox to int and compare (VB.net) : Type Convert « Language Basics « ASP.Net






Convert value from asp:TextBox to int and compare (VB.net)

<%@ Page Language="VB" %>
<script runat="server">
    Sub Reset()
    
      Textbox1.Text = ""
      Textbox2.Text = "0"
    
    End Sub
    
    Sub Page_Load(sender As Object, e As EventArgs)
    
      If Not Page.IsPostback
        Reset()
      End If
    
    End Sub
    
    Sub btnSubmit_Click(sender As Object, e As EventArgs)
    
      If cint(textbox2.text) < 20 Then
    
        label1.text = "Hi " & textbox1.text & ", you are " & textbox2.text & ", which is young!"
    
      Else If cint(textbox2.text) < 40 Then
      
        label1.text = "Hi " & textbox1.text & ", you are " & textbox2.text & ", which means you're middle-aged!"
    
      Else 
    
        label1.text = "Hi " & textbox1.text & ", you're old!"
    
      End If
    
    End Sub
    
    Sub btnReset_Click(sender As Object, e As EventArgs)
    
      Reset()
    
    End Sub

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
            Enter your name: 
            <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
        </p>
        <p>
            Enter you age: 
            <asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
        </p>
        <p>
            <asp:Button id="btnSubmit" onclick="btnSubmit_Click" runat="server" Text="Submit"></asp:Button>
            &nbsp; 
            <asp:Button id="btnReset" onclick="btnReset_Click" runat="server" Text="Reset"></asp:Button>
        </p>
        <p>
            <asp:Label id="Label1" runat="server"></asp:Label>
        </p>
    </form>
</body>
</html>

           
       








Related examples in the same category

1.Convert string to double (VB.net)
2.Convert int value to string (VB.net)
3.Convert selected date from asp:Calendar to long string (VB.net)
4.Convert value in asp:TextBox to int in try catch block (VB.net)
5.Convert value in asp:TextBox to date in try catch block (VB.net)
6.Convert value in asp:TextBox to bool in try catch block (VB.net)
7.Convert Now (current date) to string (C#)
8.Output ASCII Code (C#)
9.Convert String to int and decimal (C#)
10.Convert double and date to string (C#)
11.Int, String and date variables (C#)
12.Read string from asp textbox and format it to DateTime (C#)
13.Convert int to String (C#)
14.Convert date to string (C#)