samedi 16 décembre 2017

How to use nested if-else in vb.net

I am doing calculator and I wrote codes if user doesn't enter value to num1 and num2 it will give message to the screen and I did it with if-else. It is working for num1 and operator but not num2. How can I fix it?

If TextBox1.Text = "" Or TextBox2.Text = "" Then
            If TextBox1.Text = "" Then
                MsgBox("Please enter data to number 1 ")
                TextBox1.Focus()
                Label1.ForeColor = Color.Red
            Else
                Label1.ForeColor = SystemColors.ControlText
            End If
        ElseIf TextBox1.Text = "" Or TextBox2.Text = "" Then
            If TextBox2.Text = "" Then
                MsgBox("Please enter data to number 2")
                TextBox2.Focus()
                Label2.ForeColor = Color.Red
            Else
                Label1.ForeColor = SystemColors.ControlText
            End If
        End If 

Aucun commentaire:

Enregistrer un commentaire