Error not filling in program fields

0

I created a program in VisualStudio that uses 4 TextBox, and when I do not put anything in the 4 TextBox and then I click the button that adds what is inside the 4 TextBox program of the error, how can I replace this error with a message of type "Fill in the fields before continuing"?

    
asked by anonymous 11.07.2015 / 06:30

1 answer

0

You can test all of them before doing the operation:

if txt1.text="" or txt2.text = "" or txt3.text = "" or txt4.text = "" Then
    MsgBox("Preencha todos os campos!")
End If

Or you can assign 0 for textboxes that are empty:

if txt1.text= "" Then
    txt1.text = "0"
End If
' ....

Or direct in the comparison, convert to integers:

Dim resultado as integer = CInt(txt1.text) + CInt(txt2.text) '....
    
11.07.2015 / 07:21