Your browser does not seem to support CSS. If images appear below, please disregard them.
It appears that you're running an Ad-Blocker. This site is monetized by Advertising and by User Donations; we ask that if you find this site helpful that you whitelist us in your Ad-Blocker, or make a Donation to help aid in operating costs.
Previous Thread
Next Thread
Print Thread
Rate This Thread
#17539 - 12/03/04 05:42 AM Help with Program  
Joined: Dec 2004
Posts: 1
Lucid Offline
Junior Member
Lucid  Offline
Junior Member

Joined: Dec 2004
Posts: 1
The purpose of the program is to simulate rolling a six sided die. Then the program keeps track of the frequency of each roll, the number of total rolls and the probability . My problem is that every time my program simulates rolling a one it prints to Frq1 and does not increment correctly. I want it to increment each time by one starting from a value of zero. Any help would be greatly appreciated.

Private Sub Calculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calculate.Click
Dim Frequency As Double
Dim Probability As Decimal
Dim DieNumber As Integer
Dim One, Two, Three, Four, Five, Six As Integer

One = 0


DieNumber = CInt(Int((6 * Rnd()) + 1))

Select Case True
Case DieNumber = 1
One = One + 1

GoTo IncrementCounter

End Select

Sponsored Links
#17540 - 12/12/04 09:33 PM Re: Help with Program  
Joined: Apr 2004
Posts: 34
n0mel Offline
Junior Member
n0mel  Offline
Junior Member

Joined: Apr 2004
Posts: 34
You know, a do loop would work just as well as a goto. People might make fun of you if you use gotos.

Look at where your end select is. (wink wink).

Not that your way is wrong, but another way to do what you're doing is to use an array, such as

dim dienumbers(5) as integer

then, you could do

DieNumber = CInt(Int((6 * Rnd()) + 1))
other stuff
dienumbers(dienumber-1) = dienumbers(dienumber-1) + 1
other stuff

Since the array starts at 0, all values for one would be stored in dienumbers(0), and all from 6 would be in dienumbers(5). If you didn't mind, you could waste the first element of the array and use dim dienumbers(6) and dienumbers(dienumber) = blah.

The benefit of this way is not as much typing for you

This is the first time I've seen code. Doesn't look too different from vb6. What is with the ") Handles Calculate.Click"? Can you specify the subroutine for an event?

Member Spotlight
Portland, OR; USA
Posts: 7,197
Joined: February 2002
Show All Member Profiles 
Forum Statistics
Average Daily Posts2
Most Online1,567
Apr 25th, 2010
Latest Postings
adidas zx flux femme
by Meyershello on 01/17/17 03:43 AM
adidas zx 700 baratas
by Meyershello on 01/17/17 03:43 AM
nike air pegasus 89 baratas
by Meyershello on 01/17/17 03:36 AM
adidas superstar dame sort
by Meyershello on 01/17/17 03:33 AM
by Gremelin on 01/14/17 07:03 PM
Top Posters(All Time)
UGN Security 40,883
Gremelin 7,197
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Liked Users (All Time)
§intå× Likes: 3
Black Beard Likes: 1
Cold Sunn Likes: 1
Crime Likes: 1
Cyrez Likes: 1
fleshwound Likes: 1
Ghost Likes: 2
Gremelin Likes: 12
Ice Likes: 1
ninjaneo Likes: 1
Top Liked Users (30 Days)
fleshwound Likes: 1
Powered by UBB.threads™ PHP Forum Software 7.6.0
(Snapshot build 20160902)