• Log in or sign up for an account here: https://www.sythe.org/login

[Programming]Reported Post by Blupig

Status
Not open for further replies.

Blupig

BEEF TOILET

$5 USD Donor
Joined
Nov 23, 2006
Sythe Gold
1,609
Messages
7,145
Age
33
Location
Canada
Valentine's Singing Competition Winner
Sythe Awards 2015 Winner
Sythe Awards 2016 Winner
Sythe Awards 2020 Winner
Member of the Month Winner
MushyMuncher
Gohan has AIDS
Extreme Homosex
World War 3
I'm LAAAAAAAME
Discord Verified
Off Topic Participant
Blupig has reported a post.

Reason:
move to VB.net
Post: Help with random dice
Forum: Visual Basic
Assigned Moderators: N/A

Posted by: redawsomeness
Original Content:
Alright so I was assigned this project in class, but I felt like playing games at the time lol so I decided that I would do it at home for "study material" for the final.

I have the program built, and its working. But, it won't change the numbers every time, like it's not fully randomized or something. The numbers do change every time I do open and close the program though, but it doesn't change during the same time that the program is open.

If anybody could help me, it would be great :)

Here is a quote from the document with all the exercises on it and what he wants us to do on it:
DL ex 3.Write a program that repeatedly "throws" a pair of dice and tallies the number of tosses and the number of tosses that equal (lucky) seven. The program should stop when 100 lucky sevens have been tossed. The program should then report the approximate odds of tossing a lucky seven. The odds will be "1 in" followed by the result of dividing the total number of tosses by the number of sevens tossed. Hint: Use two random numbers, one for each die.

And then here is my source code:
Public Class Form1
Dim intDice1 As Integer
Dim intDice2 As Integer
Dim int7 As Integer
Dim intNot7 As Integer
'Treat intNot7 as if it was intRolled because by the time I had finished typing in the code
'I had noticed that I didn't need this variable so I treated it as if it was intRolled
Dim intDiceAnswer As Integer
Dim intPercentage As Integer
Private Sub btnRoll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRoll.Click
Me.lbl7Answer2.Text = Nothing
Me.lblPercentageAnswer2.Text = Nothing
Me.lblRolledAnswer2.Text = Nothing
Do Until int7 = 100
Randomize()
intDice1 = Int(Rnd() * 6) + 1
intDice2 = Int(Rnd() * 6) + 1
intDiceAnswer = intDice1 + intDice2
If intDiceAnswer = 7 Then
int7 = int7 + 1
intNot7 = intNot7 + 1
ElseIf intDiceAnswer = 1 Then
intNot7 = intNot7 + 1
ElseIf intDiceAnswer = 2 Then
intNot7 = intNot7 + 1
ElseIf intDiceAnswer = 3 Then
intNot7 = intNot7 + 1
ElseIf intDiceAnswer = 4 Then
intNot7 = intNot7 + 1
ElseIf intDiceAnswer = 5 Then
intNot7 = intNot7 + 1
ElseIf intDiceAnswer = 6 Then
intNot7 = intNot7 + 1
ElseIf intDiceAnswer = 8 Then
intNot7 = intNot7 + 1
ElseIf intDiceAnswer = 9 Then
intNot7 = intNot7 + 1
ElseIf intDiceAnswer = 10 Then
intNot7 = intNot7 + 1
ElseIf intDiceAnswer = 11 Then
intNot7 = intNot7 + 1
ElseIf intDiceAnswer = 12 Then
intNot7 = intNot7 + 1
End If
Loop
intPercentage = int7 / intNot7 * 100
Me.lblPercentageAnswer2.Text = intPercentage
Me.lblRolledAnswer2.Text = intNot7
Me.lbl7Answer2.Text = int7
End Sub
End Class
 
Status
Not open for further replies.
Runescape Gamblingrunescape gambling
Back
Top