Saturday, 21 January 2012

how to use if statement in vb.net


How to use if statement in vb.net?
If Statements helps to decides, what to do in a given situation
To know more about if statement do this
Step1:
Open Microsoft visual studio
Step2:
File ànew project àselect the windows form application àrename it as if ststement
Step3:
Drag and drop Button, textbox1
Step4:
Double click the button1 copy the code
Code:  
Public Class Form1

    Private SubButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click
        If TextBox1.Text = "123"Then
            ' if the textbox1.text="123" condition is correct then shows this
            MessageBox.Show("hi...! ")
        Else
            ' if the textbox1.text="else"condition is incorrect then shows this
            MessageBox.Show("bye..!")
        End If
    End Sub
End Class
                                                            If the condition is correct:

If the condition is incorrect: