Test Foro de elhacker.net SMF 2.1

Programación => .NET (C#, VB.NET, ASP) => Programación General => Programación Visual Basic => Mensaje iniciado por: El_Holandes_errante en 26 Noviembre 2011, 18:19 PM

Título: Problema con variable [Solucionado]
Publicado por: El_Holandes_errante en 26 Noviembre 2011, 18:19 PM
Mi problema es el siguiente:
La aplicación debe tener estados civiles en una lista y mostrarlos en un TextBox (listo) y también debe mostrar en un Msgbox una variable que sea > = 10 al hacer click en un CommandButton introducida por un TextBox (He aquí el problema), hice esa parte pero cuando le doy click al CommadButton aparece el error y no se porque pasa esto.
Estaria muy agradecido si pudieran ayudarme.
Les dejo el code y unas imágenes:

Private Sub cmdSalir_Click()
   End
End Sub

Private Sub cmdVariable_Click()
   Dim Variable As Integer
       Variable = txtVariable.Text
       'Comprobar si la variable es mayor o igual a 10
       If Variable >= "10" And txtVariable.Text >= "10" Then
           MsgBox "El valor es mayor o igual a 10: " & Variable
           Else
               MsgBox "Debe ingresar un valor valido", vbQuestion + vbOKOnly, "Datos invalidos"
               txtVariable.SetFocus
                   Exit Sub
       End If
       
End Sub

Private Sub lvwEstadoCivil_Click()
   Dim Soltero As String
   Dim Casado As String
   Dim Divorciado As String
   Dim Viudo As String
   'Seleción de variables por lista
       Select Case lvwEstadoCivil.ListIndex
           Case 0
               Soltero = "Juan Peñaloza"
               txtNombres.Text = Soltero
           Case 1
               Casado = "Franklin Mendez"
               txtNombres.Text = Casado
           Case 2
               Divorciado = "Antonio Álvarez"
               txtNombres.Text = Divorciado
           Case 3
               Viudo = "Victor Speed"
               txtNombres.Text = Viudo
               End Select
End Sub

(http://www.fileden.com/files/2010/5/20/2865417//2011_11_26_11_47_14_704x436.bmp)
(http://www.fileden.com/files/2010/5/20/2865417/2011_11_26_11_47_23_704x436.bmp)
(http://www.fileden.com/files/2010/5/20/2865417/2011_11_26_11_47_30_704x436.bmp)
(http://www.fileden.com/files/2010/5/20/2865417/2011_11_26_11_47_37_704x436.bmp)
(http://www.fileden.com/files/2010/5/20/2865417/2011_11_26_11_48_30_1100x480.bmp)
Título: Re: Problema con variable
Publicado por: Sanlegas en 26 Noviembre 2011, 19:04 PM
tienes que usar la funcion Val(),

Código (vb) [Seleccionar]
Variable = val(txtVariable.text)

y no tiene caso que compruebes Variable y txtVariable dos veces. Salu2  :rolleyes:
Título: Re: Problema con variable
Publicado por: El_Holandes_errante en 26 Noviembre 2011, 20:03 PM
Cita de: Tenient101 en 26 Noviembre 2011, 19:04 PM
tienes que usar la funcion Val(),

Código (vb) [Seleccionar]
Variable = val(txtVariable.text)

y no tiene caso que compruebes Variable y txtVariable dos veces. Salu2  :rolleyes:

Gracias viejo!  ::)
jejejej se me paso ese de las confirmaciones.  :P