Blupig has reported a post.
Reason:
Forum: Visual Basic
Assigned Moderators: N/A
Posted by: redawsomeness
Original Content:
Reason:
Post: Help with random dicemove to VB.net
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




























