General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 30th, 2011, 08:51 PM
lance7tour lance7tour is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Posts: 2 lance7tour User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 39 m 57 sec
Reputation Power: 0
Coding Help

'Formally declare variables used by the script before trying to use them
Dim WshShl, Answer, CardImage

'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 of 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 randomly selected number
If GetRandomNumber = 3 then CardImage = "rock"
If GetRandomNumber = 2 then CardImage = "scissor"
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 = "scissor" & CardImage <> "rock" then MsgBox "Rock Breaks Scissors:Computer wins!"

If CardImage = "rock" & Answer <> "Paper" then MsgBox "Paper Covers Rock:You wins!"

If CardImage = "paper" & Answer<> "Scissors" then MsgBox "Scissors Cuts Paper:You wins!"

If CardImage = "scissor" & Answer <> "rock" then MsgBox "Rock Breaks Scissors:You wins!"

If CardImage = "paper" & Answer <> "Paper" then MsgBox "TIE!"

If CardImage = "scissor" & Answer<> "Scissors" then MsgBox "TIE!"

If CardImage = "rock" & Answer <> "rock" then MsgBox "TIE!"

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Coding Help


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap