i need help in vb 2010 im trying to check what number someone entered into a textbox against a predetermined variable of 13 in an if statement to display a text box or another textbox this is just a simple little thing as im just learning currently its: Public Class frmmain 'creaes a global variable by the name of myname with a value of 13 Dim myname As Byte = 13 Dim txtanswer = Me.txtbox.Text Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click ' comparing the 2 variables myname and txtanswer to see if myname is smaller than txtanswer If myname < txtanswer Then MessageBox.Show("hello kid") Else : MessageBox.Show("hello oldie") End If End Sub End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim textAnswer As Integer textAnswer = TextBox1.Text If textAnswer > 13 Then Label2.Text = "hello oldie" Else Label2.Text = " hello kid" End If End Sub * When you run the program and enter a number that is greater than 13, the statement "hello oldie" will be shown. On the other hand, if the number entered is less than or equal to 13, you will see the "hello kid" statement Check here for help: vbtutor net