I do not know why my MsgBox is duplicated twice, it is supposed that when the spaces are blank send a message that they are blank, all this when pressing a radio button, the first time it works, but in the Second, the third one already shows the message 2 times. I leave the code:
Function validarBlancos(ByVal textoUno As String, ByVal textoDos As String) As Boolean
Return String.IsNullOrEmpty(textoUno) Or String.IsNullOrEmpty(textoDos)
End Function
and in the following code I call the function:
Private Sub rbtnSumar_CheckedChanged(sender As Object, e As EventArgs) Handles rbtnSumar.CheckedChanged
MsgBox("bandera suma")
If Not validarBlancos(txtNumeroUno.Text.Trim, txtNumeroDos.Text.Trim) Then
numeroUno = Integer.Parse(txtNumeroUno.Text)
numeroDos = Integer.Parse(txtNumeroDos.Text)
If rbtnSumar.Checked = True Then
txtResultado.Text = numeroUno + numeroDos
End If
Else
MsgBox("Espacio en blanco... Reintente", vbExclamation, "Espacio en blanco,suma")
End If
End Sub
Private Sub rbtnRestar_CheckedChanged(sender As Object, e As EventArgs) Handles rbtnRestar.CheckedChanged
MsgBox("bandera resta")
If Not validarBlancos(txtNumeroUno.Text.Trim, txtNumeroDos.Text.Trim) Then
numeroUno = Integer.Parse(txtNumeroUno.Text)
numeroDos = Integer.Parse(txtNumeroDos.Text)
If rbtnRestar.Checked = True Then
txtResultado.Text = numeroUno - numeroDos
End If
Else
MsgBox("Espacio en blanco... Reintente",, "Espacio en blanco,resta")
End If
End Sub
Private Sub rbtnMultiplicar_CheckedChanged(sender As Object, e As EventArgs) Handles rbtnMultiplicar.CheckedChanged
MsgBox("bandera multi")
If Not validarBlancos(txtNumeroUno.Text.Trim, txtNumeroDos.Text.Trim) Then
numeroUno = Integer.Parse(txtNumeroUno.Text)
numeroDos = Integer.Parse(txtNumeroDos.Text)
If rbtnMultiplicar.Checked = True Then
txtResultado.Text = numeroUno * numeroDos
End If
Else
MsgBox("Espacio en blanco... Reintente",, "Espacio en blanco,multi")
End If
End Sub
Private Sub rbtnDividir_CheckedChanged(sender As Object, e As EventArgs) Handles rbtnDividir.CheckedChanged
MsgBox("bandera dividir")
If Not validarBlancos(txtNumeroUno.Text.Trim, txtNumeroDos.Text.Trim) Then
numeroUno = Integer.Parse(txtNumeroUno.Text)
numeroDos = Integer.Parse(txtNumeroDos.Text)
If rbtnDividir.Checked = True Then
If numeroDos = 0 Then
MsgBox("No puede dividir por 0, Reintente")
txtNumeroDos.Clear()
Else
txtResultado.Text = numeroUno / numeroDos
End If
End If
Else
MsgBox("Espacio en blanco... Reintente",, "Espacio en blanco,dividir")
End If
End Sub