Pregunta:
Error en Visual Basic?
Dam.
2009-05-14 06:19:43 UTC
Tengo este codigo
Dim valor As Integer
aux = valor
valor = InputBox("Cuantos Datos desea ingresar?")
ReDim Mat(valor, 4) As Integer
Dim aux1 As Single
Dim aux2 As Single
Dim aux3 As Single
Dim aux4 As Single
For x = 1 To valor
For y = 1 To 4
aux1 = InputBox("Ingrese El Apellido y Nombre") & aux2 = InputBox("Ingrese La Edad:") & aux3 = InputBox("Ingrese El Telefono:") & aux4 = InputBox("Ingrese EL Email:")
Next y
Next x
End Sub

y Me Da "Erro 13"
no coinciden los tipos

en la parte de inputbox me lo marca con amarillo, alguien sabe porq?
Tres respuestas:
anonymous
2009-05-14 06:33:53 UTC
1. ReDim Mat(valor, 4) As Integer

Le estamos indicando crear una matriz que sólo almacene numeros.



2. Cuando se pide el valor de "Ingrese El Apellido y Nombre", por logica escribos letras, luego cuando intentamos agregar esas letras, digamos "Pedro Salas", no puede ser almacenado en una matriz "Integer".



Solución: declara la matriz de esta forma:

ReDim Mat(valor, 4) As String



Además, reordene el código fuente de la siguiente forma:



Dim NumPersonas As Integer

NumPersonas = InputBox("Cuantos Datos desea ingresar?")

ReDim mat(NumPersonas, 4) As String



Dim aux1 As String

Dim aux2 As Integer

Dim aux3 As String

Dim aux4 As String



For X = 1 To NumPersonas

'For Y = 1 To 4

aux1 = InputBox("Ingrese El Apellido y Nombre")

aux2 = InputBox("Ingrese La Edad:")

aux3 = InputBox("Ingrese El Telefono:")

aux4 = InputBox("Ingrese EL Email:")



mat(X, 1) = aux1

mat(X, 2) = aux2

mat(X, 3) = aux3

mat(X, 4) = aux4

'Next Y

Next X



Saludos, espero haber sido de ayuda.
?
2009-05-14 07:56:59 UTC
si declaras una variable integer y otras single...va a marcar ese error...
Julio Sanz
2009-05-14 06:45:10 UTC
Private Sub Form_Load()

Dim valor As Integer

valor = InputBox("Cuantos Datos desea ingresar?")

ReDim mat(valor, 4) As String

Dim aux1 As String

Dim aux2 As String

Dim aux3 As String

Dim aux4 As String

For x = 1 To valor

aux1 = InputBox("Ingrese El Apellido y Nombre")

aux2 = InputBox("Ingrese La Edad:")

aux3 = InputBox("Ingrese El Telefono:")

aux4 = InputBox("Ingrese EL Email:")

mat(x, 1) = aux1

mat(x, 2) = aux2

mat(x, 3) = aux3

mat(x, 4) = aux4

Next x

For x = 1 To valor

MsgBox (mat(x, 1) & " " & mat(x, 2) & " " & mat(x, 3) & " " & mat(x, 4))

Next x

End Sub


Este contenido se publicó originalmente en Y! Answers, un sitio web de preguntas y respuestas que se cerró en 2021.
Loading...