Home » VB.NET Basics » 06 - Conditional Logic
6
Conditional Logic and User Form
Using Conditional Logic with the User Form
Make a new user form and arrange it as seen below.
You can toggle the starting user form of your application by selecting "My Project" on the Solution Explorer window and then choose "Startup form."
Double click the button in the middle of your new user form and then write code that will identify if x is a positive, a negative, or neither a positive nor a negative integer. Hint: Review the code awhile ago and infuse it to the user form.
The code for identifying if x is a positive or a negative integer may look similar to the code below.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As Integer
Dim result As String
x = TextBox1.Text
Select Case x
Case Is < 0
result = "Negative"
Case Is = 0
result = "Neither"
Case Is > 0
result = "Positive"
End Select
TextBox2.Text = result
End Sub