tbirkhimer
asked on
Counter not counting right when I try to compare random numbers.
Public Dim numDice As Long
Public Dim numDice2 As Long
Public Dim newResult1 As String
Public Dim newResult2 As String
Public Sub formMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblPlay.Text = 0
End Sub
Public Sub textBoxNumDice_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles textBox6SidedNumDice.Leave
Dim numDice As Long
Try
numDice = System.Convert.ToInt64(sen der.Text() )
Catch exp As System.FormatException
sender.Text() = "1"
Catch exp As System.OverflowException
sender.Text() = "1"
End Try
If (numDice <= 0) Then
sender.Text() = "1"
End If
End Sub
Public Sub buttonSided_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button6Sided.Click
Select Case sender.Text()
Case "6" '6-Sided Dice
Randomize()
numDice = textBox6SidedNumDice.Text( )
textBox1.Text() = Int((numDice * 52) * Rnd() + (numDice * 1))
newResult1 = textbox1.Text + Microsoft.VisualBasic.ChrW (13) + Microsoft.VisualBasic.ChrW (10)
Randomize()
numDice2 = textBox6SidedNumDice2.Text ()
textBox2.Text() = Int((numDice2 * 52) * Rnd() + (numDice2 * 1))
newResult2 = textBox2.Text + Microsoft.VisualBasic.ChrW (13) + Microsoft.VisualBasic.ChrW (10)
butget.Text = newResult1
butget2.Text = newResult2
butget.Visible = True
butget2.Visible = True
End Select
If (textBox1.Text > textBox2.Text) Then
lblPlay.Text = lblPlay.Text + 1
Else If (textBox2.Text > textBox1.Text)
lblPlay.Text = lblPlay.Text
End If
End Sub
I have tried comparing newResuult1 to newResult2. butget.text() to butget2.text(). The counter seems to count when ever it wants. EXAMPLE : When first random number is greater then second random number I want it to count as 1 and so on. but when second number is less then first I don't want it to count, Ireally don't care if it is equal to number. Some time counts sometimes it doesn't like I get first random number 20 second random number 5, it counts, then I might get same result it doesn't count. Other example I get first random number 3 and second random number 10. It somtimes counts that for some reason or the other
Public Dim numDice2 As Long
Public Dim newResult1 As String
Public Dim newResult2 As String
Public Sub formMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblPlay.Text = 0
End Sub
Public Sub textBoxNumDice_Leave(ByVal
Dim numDice As Long
Try
numDice = System.Convert.ToInt64(sen
Catch exp As System.FormatException
sender.Text() = "1"
Catch exp As System.OverflowException
sender.Text() = "1"
End Try
If (numDice <= 0) Then
sender.Text() = "1"
End If
End Sub
Public Sub buttonSided_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button6Sided.Click
Select Case sender.Text()
Case "6" '6-Sided Dice
Randomize()
numDice = textBox6SidedNumDice.Text(
textBox1.Text() = Int((numDice * 52) * Rnd() + (numDice * 1))
newResult1 = textbox1.Text + Microsoft.VisualBasic.ChrW
Randomize()
numDice2 = textBox6SidedNumDice2.Text
textBox2.Text() = Int((numDice2 * 52) * Rnd() + (numDice2 * 1))
newResult2 = textBox2.Text + Microsoft.VisualBasic.ChrW
butget.Text = newResult1
butget2.Text = newResult2
butget.Visible = True
butget2.Visible = True
End Select
If (textBox1.Text > textBox2.Text) Then
lblPlay.Text = lblPlay.Text + 1
Else If (textBox2.Text > textBox1.Text)
lblPlay.Text = lblPlay.Text
End If
End Sub
I have tried comparing newResuult1 to newResult2. butget.text() to butget2.text(). The counter seems to count when ever it wants. EXAMPLE : When first random number is greater then second random number I want it to count as 1 and so on. but when second number is less then first I don't want it to count, Ireally don't care if it is equal to number. Some time counts sometimes it doesn't like I get first random number 20 second random number 5, it counts, then I might get same result it doesn't count. Other example I get first random number 3 and second random number 10. It somtimes counts that for some reason or the other
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
If (newResult1 > newResult2) Then
lblPlay.Text = lblPlay.Text + 1
Else
lblPlay.Text = lblPlay.Text
End If
lblPlay.Text = lblPlay.Text + 1
Else
lblPlay.Text = lblPlay.Text
End If
e.g.
If Cint(textBox1.Text) > Cint(textBox2.Text) Then
lblPlay.Text = lblPlay.Text + 1
Else If Cint(textBox2.Text) > Cint(textBox1.Text)
lblPlay.Text = lblPlay.Text
End If
-M