473,394 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

logic check

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
Feb 19 '08 #1
2 1285
On Feb 19, 2:15*pm, jdrott1 <jonathandr...@gmail.comwrote:
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
Feb 19 '08 #2
On 2008-02-19, jdrott1 <jo***********@gmail.comwrote:
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

--
Tom Shelton
Feb 19 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ted Singh | last post by:
(I apologize in advance if this is an obvious question, my experience is more with console or client-only apps) I am trying to build an web-based HTML UI, which will work with a web-server on...
7
by: David Shorthouse | last post by:
I am attempting to create a "new account creation" asp, but would ideally like the routine to check the Access db for an existing email address and username (called UID below). The select query...
2
by: Simon Harvey | last post by:
Hi all, I was wondering how most developers handle the initial startup of their Windows Forms applications? When you make an application in Visual Studio, the IDE places Main in the form that...
1
by: Kondapanaidu | last post by:
Hi, What is the logic to compare Values. First array={5,5,6,7}; Second array={5,3,3,2}; Explanation: 1.First array first element is greater than the second array first element, No need to...
0
by: Wim Vanhoof | last post by:
----------------------------------------------------------- WLPE' 06 - CALL FOR PAPERS Workshop on Logic-based Methods in Programming Environments (satellite workshop of ICLP’06) August...
24
by: cassetti | last post by:
Here's the issue: I have roughly 20 MS excel spreadsheets, each row contains a record. These records were hand entered by people in call centers. The problem is, there can and are duplicate...
6
by: C# newbie with big problems | last post by:
Ok, I am building a product configurator which works quite well except for a few bugs. It has a couple of listboxes and a checked list box. Now the checked list box holds upgrades for products...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
0
by: Wim Vanhoof | last post by:
----------------------------------------------------------- WLPE' 07 - CALL FOR PAPERS Workshop on Logic-based Methods in Programming Environments (satellite workshop of ICLP'07) ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.