error en caja de texto
Publicado por Antonio (1 intervención) el 15/06/2009 01:24:21
Hola:
Tengo un pequeño programa hecho con el visual de word, está acabado y funcionando, el problema me surge porque al final he querido que si en una caja de texto que va a contener números de tipo currency, este vacia por olvido, o se teclea letras, el error me lo recoja un msgbox y poder corregirlo.El caso es que me funciona en un punto determinado y en otros no hay manera, me dá error de no coincidencia de tipos:
Dim A As Currency, A1 As Currency, A2 As Currency, A3 As Currency, A4 As Currency
If Not IsNumeric(L1.Text) Or L1 = " " Then
L1.Text = " "
A1 = 0
MsgBox "HA INTRODUCIDO LETRAS EN VEZ DE NUMEROS O LA CASILLA ESTA VACIA, pulse Aceptar y corrigalo, GRACIAS", 0, "ERROR "
End If
A = KWhf.Text
If A < 0 Then
L1.Text = " "
L2.Text = " "
A3 = A / 2
A4 = A3
Else
A1 = L1.Text--------------------->Da error, no coinciden los tipos
A2 = L2.Text
A3 = A2 - A1
A4 = A - A3
End If
Kwhpd.Caption = Format(A3, formato)
KWhbd.Caption = Format(A4, formato)
EN CAMBIO AQUI VA PERFECTO:
Dim D As Currency, D1 As Currency, D2 As Currency
D = DKwg.Text
E = Kwhg.Text
If E < 0 Or Not IsNumeric(Kwhg.Text) Or Kwhg = " " Then
E = 0
Kwhg.Text = " "
MsgBox "HA PUESTO SIGNO NEGATIVO AL NÚMERO, HA INTRODUCIDO LETRAS EN VEZ DE NUMEROS O LA CASILLA ESTA VACIA, pulse Aceptar y corrigalo, GRACIAS", 0, "ERROR"
End If
If A3 >= E And A4 >= E Then
D1 = D / 2
D2 = D1
Else
D1 = C1 * D / C
D2 = C2 * D / C
End If
DKwhb.Caption = Format(D1, formato)
DKwhp.Caption = Format(D2, formato)
Oye, gracias
Tengo un pequeño programa hecho con el visual de word, está acabado y funcionando, el problema me surge porque al final he querido que si en una caja de texto que va a contener números de tipo currency, este vacia por olvido, o se teclea letras, el error me lo recoja un msgbox y poder corregirlo.El caso es que me funciona en un punto determinado y en otros no hay manera, me dá error de no coincidencia de tipos:
Dim A As Currency, A1 As Currency, A2 As Currency, A3 As Currency, A4 As Currency
If Not IsNumeric(L1.Text) Or L1 = " " Then
L1.Text = " "
A1 = 0
MsgBox "HA INTRODUCIDO LETRAS EN VEZ DE NUMEROS O LA CASILLA ESTA VACIA, pulse Aceptar y corrigalo, GRACIAS", 0, "ERROR "
End If
A = KWhf.Text
If A < 0 Then
L1.Text = " "
L2.Text = " "
A3 = A / 2
A4 = A3
Else
A1 = L1.Text--------------------->Da error, no coinciden los tipos
A2 = L2.Text
A3 = A2 - A1
A4 = A - A3
End If
Kwhpd.Caption = Format(A3, formato)
KWhbd.Caption = Format(A4, formato)
EN CAMBIO AQUI VA PERFECTO:
Dim D As Currency, D1 As Currency, D2 As Currency
D = DKwg.Text
E = Kwhg.Text
If E < 0 Or Not IsNumeric(Kwhg.Text) Or Kwhg = " " Then
E = 0
Kwhg.Text = " "
MsgBox "HA PUESTO SIGNO NEGATIVO AL NÚMERO, HA INTRODUCIDO LETRAS EN VEZ DE NUMEROS O LA CASILLA ESTA VACIA, pulse Aceptar y corrigalo, GRACIAS", 0, "ERROR"
End If
If A3 >= E And A4 >= E Then
D1 = D / 2
D2 = D1
Else
D1 = C1 * D / C
D2 = C2 * D / C
End If
DKwhb.Caption = Format(D1, formato)
DKwhp.Caption = Format(D2, formato)
Oye, gracias
Valora esta pregunta


0