Guest User

Untitled

a guest
Feb 20th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. Option Explicit
  2.  
  3. Dim strSecretColor1 As String
  4. Dim strSecretColor2 As String
  5. Dim strSecretColor3 As String
  6. Dim intNumTries As Integer
  7.  
  8. Private Sub Form_Load()
  9. strSecretColor1 = "R"
  10. strSecretColor2 = "Y"
  11. strSecretColor3 = "B"
  12. intNumTries = 0
  13. End Sub
  14.  
  15. Private Sub cmdCheckGuess_Click()
  16. Dim intColorsCorrect As Integer, intPosCorrect As Integer
  17. Dim strGuessColor1 As String, strGuessColor2 As String
  18. Dim strGuessColor3 As String
  19.  
  20. intNumTries = intNumTries + 1
  21. intColorsCorrect = 0
  22. intPosCorrect = 0
  23.  
  24. strGuessColor1 = txtColor1
  25. strGuessColor2 = txtColor2
  26. strGuessColor3 = txtColor3
  27.  
  28. If strGuessColor1 = strSecretColor1 And strGuessColor2 = strSecretColor2 And strGuessColor3 = strSecretColor3 Then
  29. intColorsCorrect = 3
  30. intPosCorrect = 3
  31. MsgBox "Number of tries: " & intNumTries
  32. Else
  33. If strGuessColor1 = strSecretColor1 Then
  34. intColorsCorrect = intColorsCorrect + 1
  35. intPosCorrect = intPosCorrect + 1
  36. ElseIf strGuessColor1 = strSecretColor2 Or strGuessColor1 = strSecretColor3 Then
  37. intColorsCorrect = intColorsCorrect + 1
  38. End If
  39. If strGuessColor2 = strSecretColor2 Then
  40. intColorsCorrect = intColorsCorrect + 1
  41. intPosCorrect = intPosCorrect + 1
  42. ElseIf strGuessColor2 = strSecretColor1 Or strGuessColor2 = strSecretColor3 Then
  43. intColorsCorrect = intColorsCorrect + 1
  44. End If
  45. If strGuessColor3 = strSecretColor3 Then
  46. intColorsCorrect = intColorsCorrect + 1
  47. intPosCorrect = intPosCorrect + 1
  48. ElseIf strGuessColor3 = strSecretColor1 Or strGuessColor3 = strSecretColor2 Then
  49. intColorsCorrect = intColorsCorrect + 1
  50. End If
  51. End If
  52.  
  53. lblColorsCorrect = intColorsCorrect
  54. lblPositionsCorrect = intPosCorrect
  55. End Sub
  56.  
  57. Private Sub cmdDone_Click()
  58. Unload Me
  59. End Sub
Add Comment
Please, Sign In to add comment