-
April 30th, 2013, 03:39 PM
#1
VB2010 help wanted.
I am building a WAR card game program using images, arrays, and a shuffle sub. Can anyone help me get it working right. I can't get the program to add scores into the text-boxes assigned. I also need to get the shuffle sub to work using the designated button. When shuffle is pushed the score is not to be cleared.
Code:
Public Class Form1
Dim img1, img2, img3, p1p, p2p, dec As Image
Dim value(11) As Integer
Private Sub btnShuffle_Click(sender As System.Object, e As System.EventArgs) Handles btnShuffle.Click
End Sub
Private Sub btnDraw_Click(sender As System.Object, e As System.EventArgs) Handles btnDraw.Click
boom(img1)
Player1Play.Image = img1
boom(img2)
Player2Play.Image = img2
boomer(img3)
Decision.Image = img3
p1p = Player1Play.Image
p2p = Player2Play.Image
dec = Decision.Image
If p1p = 1 And p2p <= 2 Then
End If
End Sub
Private Sub btnClear_Click(sender As System.Object, e As System.EventArgs) Handles btnClear.Click
P1score.Text = 0
P2score.Text = 0
End Sub
Private Sub btnExit_Click(sender As System.Object, e As System.EventArgs) Handles btnExit.Click
Close()
End Sub
Public Sub shuffel()
Dim switch, number_of_cards, value(51), tempval As Integer
Dim tempcard, card(12) As Image
number_of_cards = 52
For i = 1 To number_of_cards
switch = Int(Rnd() * number_of_cards + 1)
tempval = value(i)
value(i) = value(switch)
value(switch) = tempval
tempcard = card(i)
card(i) = card(switch)
card(switch) = tempcard
Next
End Sub
Sub boom(ByRef imgPop)
Dim intRand As Integer
intRand = Int(Rnd(51) * 10) + 1
If intRand = 1 Then
imgPop = My.Resources.aceh
ElseIf intRand = 2 Then
imgPop = My.Resources.twoh
ElseIf intRand = 3 Then
imgPop = My.Resources.threeh
ElseIf intRand = 4 Then
imgPop = My.Resources.fourh
ElseIf intRand = 5 Then
imgPop = My.Resources.fiveh
ElseIf intRand = 6 Then
imgPop = My.Resources.sixh
ElseIf intRand = 7 Then
imgPop = My.Resources.sevenh
ElseIf intRand = 8 Then
imgPop = My.Resources.eighth
ElseIf intRand = 9 Then
imgPop = My.Resources.nineh
ElseIf intRand = 10 Then
imgPop = My.Resources.tenh
ElseIf intRand = 11 Then
imgPop = My.Resources.jackh
ElseIf intRand = 12 Then
imgPop = My.Resources.queenh
ElseIf intRand = 13 Then
imgPop = My.Resources.kingh
ElseIf intRand = 14 Then
imgPop = My.Resources.acec
ElseIf intRand = 15 Then
imgPop = My.Resources.twoc
ElseIf intRand = 16 Then
imgPop = My.Resources.threec
ElseIf intRand = 17 Then
imgPop = My.Resources.fourc
ElseIf intRand = 18 Then
imgPop = My.Resources.fivec
ElseIf intRand = 19 Then
imgPop = My.Resources.sixc
ElseIf intRand = 20 Then
imgPop = My.Resources.sevenc
ElseIf intRand = 21 Then
imgPop = My.Resources.eightc
ElseIf intRand = 22 Then
imgPop = My.Resources.ninec
ElseIf intRand = 23 Then
imgPop = My.Resources.tenc
ElseIf intRand = 24 Then
imgPop = My.Resources.jackc
ElseIf intRand = 25 Then
imgPop = My.Resources.queenc
ElseIf intRand = 26 Then
imgPop = My.Resources.kingc
ElseIf intRand = 27 Then
imgPop = My.Resources.aced
ElseIf intRand = 28 Then
imgPop = My.Resources.twod
ElseIf intRand = 29 Then
imgPop = My.Resources.threed
ElseIf intRand = 30 Then
imgPop = My.Resources.fourd
ElseIf intRand = 31 Then
imgPop = My.Resources.fived
ElseIf intRand = 32 Then
imgPop = My.Resources.sixd
ElseIf intRand = 33 Then
imgPop = My.Resources.sevend
ElseIf intRand = 34 Then
imgPop = My.Resources.eightd
ElseIf intRand = 35 Then
imgPop = My.Resources.nined
ElseIf intRand = 36 Then
imgPop = My.Resources.tend
ElseIf intRand = 37 Then
imgPop = My.Resources.jackd
ElseIf intRand = 38 Then
imgPop = My.Resources.queend
ElseIf intRand = 39 Then
imgPop = My.Resources.kingd
ElseIf intRand = 40 Then
imgPop = My.Resources.aces
ElseIf intRand = 41 Then
imgPop = My.Resources.twos
ElseIf intRand = 42 Then
imgPop = My.Resources.threes
ElseIf intRand = 43 Then
imgPop = My.Resources.fours
ElseIf intRand = 44 Then
imgPop = My.Resources.fives
ElseIf intRand = 45 Then
imgPop = My.Resources.sixs
ElseIf intRand = 46 Then
imgPop = My.Resources.sevens
ElseIf intRand = 47 Then
imgPop = My.Resources.eights
ElseIf intRand = 48 Then
imgPop = My.Resources.nines
ElseIf intRand = 49 Then
imgPop = My.Resources.tens
ElseIf intRand = 50 Then
imgPop = My.Resources.jacks
ElseIf intRand = 51 Then
imgPop = My.Resources.queens
ElseIf intRand = 52 Then
imgPop = My.Resources.kings
Else
MessageBox.Show("Error")
End If
End Sub
Sub boomer(ByRef imgPopper)
Dim inRand As Integer
If inRand = 1 Then
imgPopper = My.Resources.winleft
ElseIf inRand = 2 Then
imgPopper = My.Resources.winright
ElseIf inRand = 3 Then
imgPopper = My.Resources.tie
Else
MessageBox.Show("Error 2")
End If
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Randomize()
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|