ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

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 27th, 2009, 04:37 PM
Timmy Timmy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 1 Timmy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 40 sec
Reputation Power: 0
Problem with VBS Code

I know its Very Basic Coding But i am somewhat new to VBS

Problem is that When you Pick either rock,paper or Scissors instead of gives your only once winner (Computer wins) it just displays all the MsgBox's


Code:
'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
  #2  
Old March 19th, 2009, 10:27 PM
Nilpo's Avatar
Nilpo Nilpo is offline
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Location: New Springfield, OH
Posts: 154 Nilpo User rank is Private First Class (20 - 50 Reputation Level)Nilpo User rank is Private First Class (20 - 50 Reputation Level)  Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 18 h 1 m 47 sec
Reputation Power: 12
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
Your statement is always evaluating to True because you're not using the proper operator. This...

If Answer = "rock" & CardImage <> "Paper" then _

Should be this...

If Answer = "rock" AND CardImage <> "Paper" then _
__________________
Don't like me? Click it.

Scripting problems? Windows questions? Ask the Windows Guru!

Stay up to date with all of my latest content. Follow me on Twitter!

Help us help you! Post your exact error message with these easy tips!

Reply With Quote
  #3  
Old January 30th, 2011, 07:59 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
? on remaining code

How is the rest of the code then coded? U listed the AND for the 1st line of code but how are the rest of the remaining code lines coded?

Reply With Quote
  #4  
Old October 19th, 2011, 07:00 AM
dktpromo dktpromo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2011
Posts: 2 dktpromo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 39 sec
Reputation Power: 0
asp

Getting the instant solution of your probolem?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Problem with VBS Code


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 - 2017, Jelsoft Enterprises Ltd.

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