Visual Basic para Aplicaciones - Esperar click del usuario

Life is soft - evento anual de software empresarial
 
Vista:

Esperar click del usuario

Publicado por Brenda (2 intervenciones) el 27/04/2017 07:40:46
Hola estoy programando un simon dice en vba y no puedo lograr que el programa espere a que el usario de click en algun boton para continuar corriendo el programa me urge ayuda por favor !!!! :(
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Antoni Masana
Val: 1.134
Oro
Ha mantenido su posición en Visual Basic para Aplicaciones (en relación al último mes)
Gráfica de Visual Basic para Aplicaciones

Esperar click del usuario

Publicado por Antoni Masana (498 intervenciones) el 27/04/2017 12:05:01
No entiendo que es lo que haces.

¿Puedes subir lo que tienes hecho para ver que hace y aconsejarte?

Saludos.
\\//_
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Esperar click del usuario

Publicado por Brenda (2 intervenciones) el 27/04/2017 12:08:33
Necesito que despues de dar click en inico pueda dar click en los botones de colores para elegir la serie, el error lo marque en mayusculas

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Public Sub CbInicio_Click()
    Dim secjuego(100) As Integer
    Dim i As Integer
    Dim puntaje As Integer
    Dim continuar As Integer
    Dim secusuario(100) As Integer
    puntaje = 0
    For i = 1 To 100
    secjuego(i) = CInt(Int((4 * Rnd()) + 1))
    Application.Range("B1").Offset(i, 0).Value = secjuego(i)
    Next i
    Do
        puntaje = puntaje + 1
        For i = 1 To puntaje
            Select Case secjuego(i)
                Case Is = 1
                    CbVerde.Picture = IVerde.Picture
                    Application.Wait (Now + TimeValue("00:00:01"))
                    CbVerde.Picture = IVerdeN.Picture
                Case Is = 2
                    CbAmarillo.Picture = IAmarillo.Picture
                     Application.Wait (Now + TimeValue("00:00:01"))
                    CbAmarillo.Picture = IAmarilloN.Picture
                Case Is = 3
                    CbAzul.Picture = IAzul.Picture
                     Application.Wait (Now + TimeValue("00:00:01"))
                    CbAzul.Picture = IAzulN.Picture
                Case Is = 4
                    CbRojo.Picture = IRojo.Picture
                     Application.Wait (Now + TimeValue("00:00:01"))
                    CbRojo.Picture = IRojoN.Picture
            End Select
        Next i
AQUI ESTA MI ERRO NO PUEDO DAR CLICK A LOS BOTONES EN MEDIO DE LA EJECUCION DE OTRO Y QUIERO SABER SI ES POSIBLE HACERLO
            Application.Wait (Now + TimeValue("00:00:01"))
            For i = 1 To puntaje
            secusuario(i) = 0
            If (CbVerde = True) Then
                secusuario(i) = Application.Range("A1").Value
            Else
                If (CbAmarillo = True) Then
                    secusuario(i) = Application.Range("A2").Value
                Else
                    If (CbAzul = True) Then
                        secusuario(i) = Application.Range("A3").Value
                    Else
                        If (CbRojo = True) Then
                            secusuario(i) = Application.Range("A4").Value
                        End If
                    End If
                End If
            End If
            Next i
         For i = 1 To puntaje
         If secusuario(i) = secjuego(i) Then
         Else
             continuar = 1
         End If
         Next i
            TbPuntaje.Text = Str(puntaje)
    Loop While (continuar = 0)
     If puntaje = 1000 Then
     MsgBox "Felicidades superaste a Simon"
     Else
     MsgBox "Perdiste"
     End If
     TbPuntaje.Text = "00"
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Antoni Masana
Val: 1.134
Oro
Ha mantenido su posición en Visual Basic para Aplicaciones (en relación al último mes)
Gráfica de Visual Basic para Aplicaciones

Esperar click del usuario

Publicado por Antoni Masana (498 intervenciones) el 27/04/2017 20:30:00
No se que carajo hace la macro ni me interesa, lo que si he visto es que cuando la ejecutas no puedes hacer nada ni con el Excel ni con el ordenador

He retocado un poco la macro y he añadido 3 líneas que son el truco del almendruco. Si te funciona, que funcionara, busca el Google para saber que hace y para que sirve.

Las lineas son la 18, 43 y 63

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Public Sub CbInicio_Click()
    Dim secjuego(100) As Integer
    Dim i As Integer
    Dim puntaje As Integer
    Dim continuar As Integer
    Dim secusuario(100) As Integer
 
    puntaje = 0
 
    For i = 1 To 100
        secjuego(i) = CInt(Int((4 * Rnd()) + 1))
        Application.Range("B1").Offset(i, 0).Value = secjuego(i)
    Next i
 
    Do
        puntaje = puntaje + 1
        For i = 1 To puntaje
            DoEvents
            Select Case secjuego(i)
                Case Is = 1
                    CbVerde.Picture = IVerde.Picture
                    Application.Wait (Now + TimeValue("00:00:01"))
                    CbVerde.Picture = IVerdeN.Picture
                Case Is = 2
                    CbAmarillo.Picture = IAmarillo.Picture
                     Application.Wait (Now + TimeValue("00:00:01"))
                    CbAmarillo.Picture = IAmarilloN.Picture
                Case Is = 3
                    CbAzul.Picture = IAzul.Picture
                     Application.Wait (Now + TimeValue("00:00:01"))
                    CbAzul.Picture = IAzulN.Picture
                Case Is = 4
                    CbRojo.Picture = IRojo.Picture
                     Application.Wait (Now + TimeValue("00:00:01"))
                    CbRojo.Picture = IRojoN.Picture
            End Select
        Next i
 
'AQUI ESTA MI ERRO NO PUEDO DAR CLICK A LOS BOTONES EN MEDIO DE LA EJECUCION DE OTRO Y QUIERO SABER SI ES POSIBLE HACERLO
 
        Application.Wait (Now + TimeValue("00:00:01"))
        For i = 1 To puntaje
            DoEvents
            secusuario(i) = 0
            If (CbVerde = True) Then
                secusuario(i) = Application.Range("A1").Value
            Else
                If (CbAmarillo = True) Then
                    secusuario(i) = Application.Range("A2").Value
                Else
                    If (CbAzul = True) Then
                        secusuario(i) = Application.Range("A3").Value
                    Else
                        If (CbRojo = True) Then
                            secusuario(i) = Application.Range("A4").Value
                        End If
                    End If
                End If
            End If
        Next i
 
        For i = 1 To puntaje
            DoEvents
            If secusuario(i) = secjuego(i) Then
            Else
                continuar = 1
            End If
        Next i
 
        TbPuntaje.Text = Str(puntaje)
    Loop While (continuar = 0)
 
    If puntaje = 1000 Then
        MsgBox "Felicidades superaste a Simon"
    Else
        MsgBox "Perdiste"
    End If
 
    TbPuntaje.Text = "00"
End Sub

Saludos.
\\//_
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar