Am trying to get this code to work where the user enters n rock,paper,or scissors and the computer randomly picks as well, it then states what each choose, once u click ok it tells who won the match but my code once it shows the 1st winner result have to keep clicking ok to get thru the rest of the winner messageboxes. what am i missing? this is a .vbs extension that i am writing up using wordpad then testing the file where it is located by dbl clicking the file and playing the game. please help.

'Formally declare variables used by the script before typing to use them

Dim WshShl, Answer, CardImage, GetRandomNumber

'Create an instance of the WScript object in order to later use the

'Popup method

Set WshShl = Wscript.CreateObject("WScript.Shell")

'Display the rules of the game

WshShl.Popup "Welcome to Rock, Paper and Scissors game. Here are the " & _
"rules for playing the game: 1. Guess the same thing as the " & _
"computer to tie. 2. Paper covers Rock and wins. 3. Rock breaks " & _
"Scissors and wins. 4. Scissors cut Paper and wins."

'Prompt the user to select a choice

Answer = InputBox("Type Paper, Rock, or Scissors.", _
"Let's play a game!")

'Time for the computer to randomly pick a choice

Randomize

GetRandomNumber = Round(FormatNumber(Int((3 * Rnd()) + 1)))

'Assign a value to the randonly selected number

If GetRandomNumber = 3 then CardImage = "Rock"
If GetRandomNumber = 2 then CardImage = "Scissors"
If GetRandomNumber = 1 then CardImage = "Paper"

'Display the game's results so that the user can see if he or she won

WshShl.Popup "You picked: " & Answer & Space(12) & "Computer picked: " & CardImage

If Answer = "Rock" & CardImage <> "Paper" Then MsgBox "Paper Covers Rock: Computer Wins!"

If Answer = "Paper" & CardImage <> "Scissors" Then MsgBox "Scissors Cuts Paper: Computer Wins!"

If Answer = "Scissors" & CardImage <> "Rock" Then MsgBox "Rock Breaks Scissors: Computer Wins!"

If CardImage = "Rock" & Answer <> "Paper" Then MsgBox "Paper Covers Rock: You Win!"

If CardImage = "Paper" & Answer <> "Scissors" Then MsgBox "Scissors Cuts Paper: You Win!"

If CardImage = "Scissors" & Answer <> "Rock" Then MsgBox "Rock Breaks Scissors: You Win!"

If CardImage = "Rock" & Answer <> "Rock" Then MsgBox "TIE!"

If CardImage = "Paper" & Answer <> "Paper" Then MsgBox "TIE!"
 
If CardImage = "Scissor" & Answer <> "Scissor" Then MsgBox "TIE!"

Since vbScript is quite similar to vb.net, I decide to give it a try.
My Notepad++ is nothing like the vb.net code editor :D, but it does quite nicely.

See if this helps as my first attempt at VbScript.

Select Case LCase(Answer)'// to Lower Case, not to be Case Sensitive.
	Case "rock"
		If CardImage = "Paper" Then MsgBox "Paper Covers Rock: Computer Wins!"
		If CardImage = "Scissors" Then MsgBox "Rock Breaks Scissors: You Win!"
		If CardImage = "Rock" Then MsgBox "TIE!" 
	Case "paper" 
		If CardImage = "Scissors" Then MsgBox "Scissors Cuts Paper: Computer Wins!"
		If CardImage = "Rock" Then MsgBox "Paper Covers Rock: You Win!"
		If CardImage = "Paper" Then MsgBox "TIE!"
	Case "scissors"
		If CardImage = "Rock" Then MsgBox "Rock Breaks Scissors: Computer Wins!"
		If CardImage = "Paper" Then MsgBox "Scissors Cuts Paper: You Win!"
		If CardImage = "Scissor" Then MsgBox "TIE!" 
End Select

Btw, interesting topic.

commented: Not bad for a .netter :) +6
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.