logic check

J

jdrott1

can someone check this logic for me? i'm trying to get a random
number between 1 and 38.

group 1-12 is winner everything else is a loser (for now)

everytime i run the logic i receive 297+ wins

Do While counter < 300
randomnumber = CInt(Int((38 - 1 + 1) * Rnd(Rnd()) + 1))
If randomnumber <= 12 Then
First12 = True
ElseIf randomnumber >= 13 <= 24 Then
Second12 = True
ElseIf randomnumber >= 25 <= 36 Then
Third12 = True
Else
zero1 = True
End If

If First12 = True Then
Wins = Wins + 1
lblWins.Text = Wins
Else
Loses = Loses + 1
lblLoses.Text = Loses
End If

counter = counter + 1
lblCounter.Text = counter & " Spins"
Loop
 
J

jdrott1

can someone check this logic for me?  i'm trying to get a random
number between 1 and 38.

group 1-12 is winner  everything else is a loser (for now)

everytime i run the logic i receive 297+ wins

Do While counter < 300
            randomnumber = CInt(Int((38 - 1 + 1) * Rnd(Rnd()) + 1))
            If randomnumber <= 12 Then
                First12 = True
            ElseIf randomnumber >= 13 <= 24 Then
                Second12 = True
            ElseIf randomnumber >= 25 <= 36 Then
                Third12 = True
            Else
                zero1 = True
            End If

            If First12 = True Then
                Wins = Wins + 1
                lblWins.Text = Wins
            Else
                Loses = Loses + 1
                lblLoses.Text = Loses
            End If

            counter = counter + 1
            lblCounter.Text = counter & " Spins"
        Loop


this would probably help

ElseIf randomnumber >= 13 And randomnumber <= 24 Then
Second12 = True
ElseIf randomnumber >= 25 And randomnumber <= 36 Then
 
T

Tom Shelton

can someone check this logic for me? i'm trying to get a random
number between 1 and 38.

group 1-12 is winner everything else is a loser (for now)

everytime i run the logic i receive 297+ wins

Do While counter < 300
randomnumber = CInt(Int((38 - 1 + 1) * Rnd(Rnd()) + 1))
If randomnumber <= 12 Then
First12 = True
ElseIf randomnumber >= 13 <= 24 Then
Second12 = True
ElseIf randomnumber >= 25 <= 36 Then
Third12 = True
Else
zero1 = True
End If

If First12 = True Then
Wins = Wins + 1
lblWins.Text = Wins
Else
Loses = Loses + 1
lblLoses.Text = Loses
End If

counter = counter + 1
lblCounter.Text = counter & " Spins"
Loop

Some things you might want to look into...

System.Random. To get a random integer between 1 and 38:
Dim r as new random()
dim randomNumber as integer = r.next(1, 39)

you also might want to look into the visual basic select case statement:

select randomNumber
case is <= 12
' do cool stuff
case 13 to 24
' do more cool stuff
case 25 to 36
' even more cool stuff
case default
' it didn't match
end select

HTH
 
J

Just_a_fan

Much simpler:

do counter=1 to 300

First12=false
Second12=false
Third12=false
case 1=false

select case CInt(Int((38 - 1 + 1) * Rnd(Rnd()) + 1))
case 1 - 12
First12=true
wins=wins+1

case 13 - 24
Second12=true

case 25 - 36
Third12=true

case else
zero1=true
end select

next

lblwins.text=wins
lbllosses = 300 - wins

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top