Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

Incremento y decremento con checkboxes

Estas en el tema de Incremento y decremento con checkboxes en el foro de Visual Basic clásico en Foros del Web. Estoy tratando de sumar y restar los valores mediante checkboxes. Tengo 2 labels que indican las cantidades, 4 checkboxes que son para incrementar y decrementar ...
  #1 (permalink)  
Antiguo 04/04/2006, 13:13
Avatar de X.Cyclop
Usuario baneado!
 
Fecha de Ingreso: diciembre-2005
Ubicación: México, D.F.
Mensajes: 1.328
Antigüedad: 18 años, 4 meses
Puntos: 0
Incremento y decremento con checkboxes

Estoy tratando de sumar y restar los valores mediante checkboxes. Tengo 2 labels que indican las cantidades, 4 checkboxes que son para incrementar y decrementar de a 1.
Tengo este código que hace todo bien, solo que incremente y decrementa de a 2, no de a 1:
Código PHP:
'Suma y resta con checkboxes
'
---------------------------------

Option Explicit
Private Sub Check1_Click()
lbl4.Caption Val(lbl4.Caption) + 1
Check1
.Value False
lbl6
.Caption Val(lbl6.Caption) + 1
End Sub

Private Sub Check2_Click()
lbl4.Caption Val(lbl4.Caption) - 1
Check2
.Value False
lbl6
.Caption Val(lbl6.Caption) - 1
End Sub

Private Sub Check3_Click()
lbl3.Caption Val(lbl3.Caption) + 1
Check3
.Value False
lbl6
.Caption Val(lbl6.Caption) + 1
End Sub

Private Sub Check4_Click()
lbl3.Caption Val(lbl3.Caption) - 1
Check4
.Value False
lbl6
.Caption Val(lbl6.Caption) - 1
End Sub

Private Sub Command1_Click()
End
End Sub

Private Sub Form_Load()
Check1.Caption "+"
Check2.Caption "-"
Check3.Caption "+"
Check4.Caption "-"
lbl1.Caption "Número 1"
lbl2.Caption "Número 2"
lbl3.Caption "0"
lbl4.Caption "0"
lbl5.Caption "El resultado es:"
Command1.Caption "Salir"
End Sub 
¿Qué está mal?


A ver si queda más claro con la imagen:
  #2 (permalink)  
Antiguo 04/04/2006, 15:18
Avatar de Developer9
(Desactivado)
 
Fecha de Ingreso: abril-2005
Ubicación: Mi Ecuador del alma
Mensajes: 4.196
Antigüedad: 19 años
Puntos: 47
Podrias explicar mejor cual es el checkbox1, 2, 3 y 4. Y que es lo que quieres hacer?

Se ve sencillo
  #3 (permalink)  
Antiguo 04/04/2006, 15:21
Avatar de X.Cyclop
Usuario baneado!
 
Fecha de Ingreso: diciembre-2005
Ubicación: México, D.F.
Mensajes: 1.328
Antigüedad: 18 años, 4 meses
Puntos: 0
Ok. Al hacer click en un checkbox se suma o se resta 1 al label de arriba y al label del resultado.
  #4 (permalink)  
Antiguo 04/04/2006, 15:23
Avatar de vbx3m  
Fecha de Ingreso: febrero-2005
Ubicación: Venezuela
Mensajes: 524
Antigüedad: 19 años, 3 meses
Puntos: 1
Puedes probar con esto:

Código:
Private Sub Check1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Label4.Caption = Val(Label4.Caption) + 1
    Label6.Caption = Val(Label6.Caption) + 1
End Sub

Private Sub Check2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Label4.Caption = Val(Label4.Caption) - 1
    Label6.Caption = Val(Label6.Caption) - 1
End Sub

Private Sub Check3_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Label3.Caption = Val(Label3.Caption) + 1
    Label6.Caption = Val(Label6.Caption) + 1
End Sub

Private Sub Check4_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Label3.Caption = Val(Label3.Caption) - 1
    Label6.Caption = Val(Label6.Caption) - 1
End Sub

Private Sub Check1_Click()
Check1.Value = False
End Sub

Private Sub Check2_Click()
Check2.Value = False
End Sub

Private Sub Check3_Click()
Check3.Value = False
End Sub

Private Sub Check4_Click()
Check4.Value = False
End Sub
__________________
ホルヘ・ラファエル・マルティネス・レオン
  #5 (permalink)  
Antiguo 04/04/2006, 15:27
Avatar de Developer9
(Desactivado)
 
Fecha de Ingreso: abril-2005
Ubicación: Mi Ecuador del alma
Mensajes: 4.196
Antigüedad: 19 años
Puntos: 47
Yo mañana te traigo otra respuesta
  #6 (permalink)  
Antiguo 04/04/2006, 15:28
Avatar de X.Cyclop
Usuario baneado!
 
Fecha de Ingreso: diciembre-2005
Ubicación: México, D.F.
Mensajes: 1.328
Antigüedad: 18 años, 4 meses
Puntos: 0
Bueno, voy a probar eso de vbx3m. Gracias

[EDIT]

Juju, salió. Gracias!
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:11.