Advertisement
maxSS

dado

May 6th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub JUEDO_DEL_DADO()
  2. Dim N
  3. Randomize
  4. N = Int(Rnd * 6) + 1
  5. Select Case N
  6. Case 1
  7. MsgBox ("Tiraste el número 1")
  8. Hoja1.Cells(4, 6) = "x"
  9. Case 2
  10. MsgBox ("Tiraste el número 2")
  11. Hoja1.Cells(3, 5) = "x"
  12. Hoja1.Cells(5, 7) = "x"
  13. Case 3
  14. MsgBox ("Tiraste el número 3")
  15. Hoja1.Cells(3, 5) = "x"
  16. Hoja1.Cells(4, 6) = "x"
  17. Hoja1.Cells(5, 7) = "x"
  18. Case 4
  19. MsgBox ("Tiraste el número 4")
  20. Hoja1.Cells(3, 5) = "x"
  21. Hoja1.Cells(5, 5) = "x"
  22. Hoja1.Cells(3, 7) = "x"
  23. Hoja1.Cells(5, 7) = "x"
  24. Case 5
  25. MsgBox ("Tiraste el número 5")
  26. Hoja1.Cells(3, 5) = "x"
  27. Hoja1.Cells(5, 5) = "x"
  28. Hoja1.Cells(4, 6) = "x"
  29. Hoja1.Cells(3, 7) = "x"
  30. Hoja1.Cells(5, 7) = "x"
  31. Case 6
  32. MsgBox ("Tiraste el número 6")
  33. Hoja1.Cells(3, 5) = "x"
  34. Hoja1.Cells(4, 5) = "x"
  35. Hoja1.Cells(5, 5) = "x"
  36. Hoja1.Cells(3, 7) = "x"
  37. Hoja1.Cells(4, 7) = "x"
  38. Hoja1.Cells(5, 7) = "x"
  39. End Select
  40. Dim tiro
  41. Randomize
  42. tiro = Int(Rnd * 6) + 1
  43. Select Case tiro
  44. Case 1
  45. MsgBox ("PC tiro el número 1")
  46. Hoja1.Cells(8, 6) = "x"
  47. Case 2
  48. MsgBox ("PC tiro el número 2")
  49. Hoja1.Cells(7, 5) = "x"
  50. Hoja1.Cells(9, 7) = "x"
  51. Case 3
  52. MsgBox ("PC tiro el número 3")
  53. Hoja1.Cells(7, 5) = "x"
  54. Hoja1.Cells(8, 6) = "x"
  55. Hoja1.Cells(9, 7) = "x"
  56. Case 4
  57. MsgBox ("PC tiro el número 4")
  58. Hoja1.Cells(7, 5) = "x"
  59. Hoja1.Cells(9, 5) = "x"
  60. Hoja1.Cells(7, 7) = "x"
  61. Hoja1.Cells(9, 7) = "x"
  62. Case 5
  63. MsgBox ("PC tiro el número 5")
  64. Hoja1.Cells(7, 5) = "x"
  65. Hoja1.Cells(9, 5) = "x"
  66. Hoja1.Cells(8, 6) = "x"
  67. Hoja1.Cells(7, 7) = "x"
  68. Hoja1.Cells(9, 7) = "x"
  69. Case 6
  70. MsgBox ("PC tiro el número 6")
  71. Hoja1.Cells(7, 5) = "x"
  72. Hoja1.Cells(8, 5) = "x"
  73. Hoja1.Cells(9, 5) = "x"
  74. Hoja1.Cells(7, 7) = "x"
  75. Hoja1.Cells(8, 7) = "x"
  76. Hoja1.Cells(9, 7) = "x"
  77. End Select
  78. Select Case tiro
  79. Case Is = N
  80. mensaje3 = "EMPATE"
  81. botones = vbOKOnly + vbCritical + vbDefaultButton1
  82. titulo = "Resultado del juego"
  83. respuesta3 = MsgBox(mensaje3, botones, titulo)
  84. Case Is < N
  85. Mensaje = "¡FELICIDADES USTED GANÓ!"
  86. botones = vbOKOnly + vbCritical + vbDefaultButton1
  87. titulo = "Resultado del juego"
  88. respuesta = MsgBox(Mensaje, botones, titulo)
  89. Case Is > N
  90. mensaje2 = "LÁSTIMA USTED PERDIÓ"
  91. botones = vbOKOnly + vbCritical + vbDefaultButton1
  92. titulo = "Resultado del juego"
  93. respuesta2 = MsgBox(mensaje2, botones, titulo)
  94. End Select
  95. End Sub
  96. Sub nuevoJuego()
  97. Hoja1.Cells(3, 5) = ""
  98. Hoja1.Cells(3, 7) = ""
  99. Hoja1.Cells(4, 5) = ""
  100. Hoja1.Cells(4, 6) = ""
  101. Hoja1.Cells(4, 7) = ""
  102. Hoja1.Cells(5, 5) = ""
  103. Hoja1.Cells(5, 7) = ""
  104. Hoja1.Cells(7, 5) = ""
  105. Hoja1.Cells(7, 7) = ""
  106. Hoja1.Cells(8, 5) = ""
  107. Hoja1.Cells(8, 6) = ""
  108. Hoja1.Cells(8, 7) = ""
  109. Hoja1.Cells(9, 5) = ""
  110. Hoja1.Cells(9, 7) = ""
  111. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement