Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub JUEDO_DEL_DADO()
- Dim N
- Randomize
- N = Int(Rnd * 6) + 1
- Select Case N
- Case 1
- MsgBox ("Tiraste el número 1")
- Hoja1.Cells(4, 6) = "x"
- Case 2
- MsgBox ("Tiraste el número 2")
- Hoja1.Cells(3, 5) = "x"
- Hoja1.Cells(5, 7) = "x"
- Case 3
- MsgBox ("Tiraste el número 3")
- Hoja1.Cells(3, 5) = "x"
- Hoja1.Cells(4, 6) = "x"
- Hoja1.Cells(5, 7) = "x"
- Case 4
- MsgBox ("Tiraste el número 4")
- Hoja1.Cells(3, 5) = "x"
- Hoja1.Cells(5, 5) = "x"
- Hoja1.Cells(3, 7) = "x"
- Hoja1.Cells(5, 7) = "x"
- Case 5
- MsgBox ("Tiraste el número 5")
- Hoja1.Cells(3, 5) = "x"
- Hoja1.Cells(5, 5) = "x"
- Hoja1.Cells(4, 6) = "x"
- Hoja1.Cells(3, 7) = "x"
- Hoja1.Cells(5, 7) = "x"
- Case 6
- MsgBox ("Tiraste el número 6")
- Hoja1.Cells(3, 5) = "x"
- Hoja1.Cells(4, 5) = "x"
- Hoja1.Cells(5, 5) = "x"
- Hoja1.Cells(3, 7) = "x"
- Hoja1.Cells(4, 7) = "x"
- Hoja1.Cells(5, 7) = "x"
- End Select
- Dim tiro
- Randomize
- tiro = Int(Rnd * 6) + 1
- Select Case tiro
- Case 1
- MsgBox ("PC tiro el número 1")
- Hoja1.Cells(8, 6) = "x"
- Case 2
- MsgBox ("PC tiro el número 2")
- Hoja1.Cells(7, 5) = "x"
- Hoja1.Cells(9, 7) = "x"
- Case 3
- MsgBox ("PC tiro el número 3")
- Hoja1.Cells(7, 5) = "x"
- Hoja1.Cells(8, 6) = "x"
- Hoja1.Cells(9, 7) = "x"
- Case 4
- MsgBox ("PC tiro el número 4")
- Hoja1.Cells(7, 5) = "x"
- Hoja1.Cells(9, 5) = "x"
- Hoja1.Cells(7, 7) = "x"
- Hoja1.Cells(9, 7) = "x"
- Case 5
- MsgBox ("PC tiro el número 5")
- Hoja1.Cells(7, 5) = "x"
- Hoja1.Cells(9, 5) = "x"
- Hoja1.Cells(8, 6) = "x"
- Hoja1.Cells(7, 7) = "x"
- Hoja1.Cells(9, 7) = "x"
- Case 6
- MsgBox ("PC tiro el número 6")
- Hoja1.Cells(7, 5) = "x"
- Hoja1.Cells(8, 5) = "x"
- Hoja1.Cells(9, 5) = "x"
- Hoja1.Cells(7, 7) = "x"
- Hoja1.Cells(8, 7) = "x"
- Hoja1.Cells(9, 7) = "x"
- End Select
- Select Case tiro
- Case Is = N
- mensaje3 = "EMPATE"
- botones = vbOKOnly + vbCritical + vbDefaultButton1
- titulo = "Resultado del juego"
- respuesta3 = MsgBox(mensaje3, botones, titulo)
- Case Is < N
- Mensaje = "¡FELICIDADES USTED GANÓ!"
- botones = vbOKOnly + vbCritical + vbDefaultButton1
- titulo = "Resultado del juego"
- respuesta = MsgBox(Mensaje, botones, titulo)
- Case Is > N
- mensaje2 = "LÁSTIMA USTED PERDIÓ"
- botones = vbOKOnly + vbCritical + vbDefaultButton1
- titulo = "Resultado del juego"
- respuesta2 = MsgBox(mensaje2, botones, titulo)
- End Select
- End Sub
- Sub nuevoJuego()
- Hoja1.Cells(3, 5) = ""
- Hoja1.Cells(3, 7) = ""
- Hoja1.Cells(4, 5) = ""
- Hoja1.Cells(4, 6) = ""
- Hoja1.Cells(4, 7) = ""
- Hoja1.Cells(5, 5) = ""
- Hoja1.Cells(5, 7) = ""
- Hoja1.Cells(7, 5) = ""
- Hoja1.Cells(7, 7) = ""
- Hoja1.Cells(8, 5) = ""
- Hoja1.Cells(8, 6) = ""
- Hoja1.Cells(8, 7) = ""
- Hoja1.Cells(9, 5) = ""
- Hoja1.Cells(9, 7) = ""
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement