Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 20th, 2005, 7:57 PM   #11
Batalia2
Newbie
 
Join Date: Mar 2005
Posts: 9
Rep Power: 0 Batalia2 is on a distinguished road
Thanx for the help but it keeps on breaking on the first RPS(1) and can;'t figure out why. I already changed the array.
Batalia2 is offline   Reply With Quote
Old Mar 21st, 2005, 3:25 PM   #12
Batalia2
Newbie
 
Join Date: Mar 2005
Posts: 9
Rep Power: 0 Batalia2 is on a distinguished road
Finnaly got it all working now just need a simple fix. When I run the program ir shows 0,1,2 instead of rock paper scissor. Can' you show me what can I add or what is wrong.

[PHP]
Dim P1 As Integer, P2 As Integer
Dim RPS(3) As Integer
Dim Winner As Integer
Dim x As Integer
Dim rock, paper, scissors As Single

lstp1.Items.Add(P1)
lstp2.Items.Add(P1)
lstwin.Items.Add(Winner)

rock = 0
paper = 1
scissors = 2


Randomize()

For x = 0 To 100

P1 = Int(3 * Rnd())
P2 = Int(3 * Rnd())

Select Case P1
Case rock
Select Case P2
Case rock
Winner = 1
Case paper
Winner = 3
Case scissors
Winner = 2
End Select

Case paper
Select Case P2
Case rock
Winner = 2
Case paper
Winner = 1
Case scissors
Winner = 3
End Select
Case scissors
Select Case P2
Case rock
Winner = 3
Case paper
Winner = 2
Case scissors
Winner = 1
End Select
End Select

lstp1.Items.Add(P1)
lstp2.Items.Add(P2)
lstwin.Items.Add("Player " & Winner)
Next
End Sub[/PHP]
Batalia2 is offline   Reply With Quote
Old Mar 21st, 2005, 3:36 PM   #13
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
You need that array. It should work as I've typed it, if you haven't set the Option Base to 1.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 21st, 2005, 4:01 PM   #14
Batalia2
Newbie
 
Join Date: Mar 2005
Posts: 9
Rep Power: 0 Batalia2 is on a distinguished road
Whenever I add this part it just crashes the program.

[PHP]Enum RPS
Rock = 0,
Paper,
Scissors
End Enum

RPS(0) = "Rock"
RPS(1) = "Paper"
RPS(2) = "Scissors"[/PHP]

Last edited by Batalia2; Mar 21st, 2005 at 4:05 PM.
Batalia2 is offline   Reply With Quote
Old Mar 21st, 2005, 4:11 PM   #15
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Put the Enum outside the function.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:09 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC