
Como validar datos?
Publicado por Cesar Mena (1 intervención) el 22/01/2022 08:22:41
ESTE ES MI CODIGO QUISIERA AGREGARLE QUE SI INGRESO UNA LETRA O NADA ME SALGA UN MENSAJE QUE DIGA " ERROR DEBE INGRESAR SOLO NUMEROS" O " RECUERDE QUE DEBE INGRESAR UN NUMERO"
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim matA(,), matB(,) As Integer
Dim a, b, c, d, i, j As Integer
a = 4
b = 4
c = 4
d = 4
ReDim matA(a, b)
ReDim matB(c, d)
MessageBox.Show("INGRESE LOS NUMEROS DE LA MATRIZ A")
For i = 0 To a - 1
For j = 0 To b - 1
matA(i, j) = InputBox("INGRESE UN NUMERO")
Next
Next
MessageBox.Show("INGRESE LOS NUMEROS DE LA MATRIZ B")
For i = 0 To a - 1
For j = 0 To b - 1
matB(i, j) = InputBox("INGRESE UN NUMERO")
Next
Next
For i = 0 To a - 1
For j = 0 To b - 1
If i = 0 Then
TextBox1.AppendText(matA(i, j) & " " & ControlChars.NullChar)
End If
If i > 0 Then
If j = 0 Then
TextBox1.AppendText(ControlChars.CrLf)
End If
TextBox1.AppendText(matA(i, j) & " " & ControlChars.NullChar)
End If
Next
Next
For i = 0 To c - 1
For j = 0 To d - 1
If i = 0 Then
TextBox2.AppendText(matB(i, j) & " " & ControlChars.NullChar)
End If
If i > 0 Then
If j = 0 Then
TextBox2.AppendText(ControlChars.CrLf)
End If
TextBox2.AppendText(matB(i, j) & " " & ControlChars.NullChar)
End If
Next
Next
For i = 0 To a - 1
For j = 0 To b - 1
If i = 0 Then
TextBox3.AppendText(matA(i, j) + matB(i, j) & " " & ControlChars.NullChar)
End If
If i > 0 Then
If j = 0 Then
TextBox3.AppendText(ControlChars.CrLf)
End If
TextBox3.AppendText(matA(i, j) + matB(i, j) & " " & ControlChars.NullChar)
End If
Next
Next
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
End Sub
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
End
End Sub
End Class
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim matA(,), matB(,) As Integer
Dim a, b, c, d, i, j As Integer
a = 4
b = 4
c = 4
d = 4
ReDim matA(a, b)
ReDim matB(c, d)
MessageBox.Show("INGRESE LOS NUMEROS DE LA MATRIZ A")
For i = 0 To a - 1
For j = 0 To b - 1
matA(i, j) = InputBox("INGRESE UN NUMERO")
Next
Next
MessageBox.Show("INGRESE LOS NUMEROS DE LA MATRIZ B")
For i = 0 To a - 1
For j = 0 To b - 1
matB(i, j) = InputBox("INGRESE UN NUMERO")
Next
Next
For i = 0 To a - 1
For j = 0 To b - 1
If i = 0 Then
TextBox1.AppendText(matA(i, j) & " " & ControlChars.NullChar)
End If
If i > 0 Then
If j = 0 Then
TextBox1.AppendText(ControlChars.CrLf)
End If
TextBox1.AppendText(matA(i, j) & " " & ControlChars.NullChar)
End If
Next
Next
For i = 0 To c - 1
For j = 0 To d - 1
If i = 0 Then
TextBox2.AppendText(matB(i, j) & " " & ControlChars.NullChar)
End If
If i > 0 Then
If j = 0 Then
TextBox2.AppendText(ControlChars.CrLf)
End If
TextBox2.AppendText(matB(i, j) & " " & ControlChars.NullChar)
End If
Next
Next
For i = 0 To a - 1
For j = 0 To b - 1
If i = 0 Then
TextBox3.AppendText(matA(i, j) + matB(i, j) & " " & ControlChars.NullChar)
End If
If i > 0 Then
If j = 0 Then
TextBox3.AppendText(ControlChars.CrLf)
End If
TextBox3.AppendText(matA(i, j) + matB(i, j) & " " & ControlChars.NullChar)
End If
Next
Next
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
End Sub
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
End
End Sub
End Class
Valora esta pregunta


0