Okay so I've been trying to get this coin toss program to work however I don't exactly understand what I did wrong. What I'm trying to do is make it so when I start the program it opens an inputbox asking the user to input the number of tosses they want and when that happens it outputs the amount of heads and tails that came out in a label on the form. So far here is what I have:
Dim intSideUp As Integer ' To indicate which side is up
Dim rand As New Random ' Random number generator
Dim tosses As String
Dim headscount As Integer
Dim tailscount As Integer
' Declaring how much it starts with.
headscount = 0
tailscount = 0
' Get a random number in the range of 0 through 1.
' 0 means tails up, and 1 means heads up.
intSideUp = rand.Next(2)
tosses = CInt(tosses)
tosses = Inputbox("How many times would you like to toss the coin?")
For
' Display the side that is up.
If intSideUp = 0 Then
' 0 means tails is up, so display the tails
' image and hide the heads image.
picTails.Visible = True
picHeads.Visible = False
tailscount = tailscount + 1
Else
' 1 means heads is up, so display the heads
' image and hide the tails image.
picHeads.Visible = True
picTails.Visible = False
headscount = headscount + 1
End if
Next
lblHeads.Text = headscount
lblTails.Text = tailscount
End Sub
Dim intSideUp As Integer ' To indicate which side is up
Dim rand As New Random ' Random number generator
Dim tosses As String
Dim headscount As Integer
Dim tailscount As Integer
' Declaring how much it starts with.
headscount = 0
tailscount = 0
' Get a random number in the range of 0 through 1.
' 0 means tails up, and 1 means heads up.
intSideUp = rand.Next(2)
tosses = CInt(tosses)
tosses = Inputbox("How many times would you like to toss the coin?")
For
' Display the side that is up.
If intSideUp = 0 Then
' 0 means tails is up, so display the tails
' image and hide the heads image.
picTails.Visible = True
picHeads.Visible = False
tailscount = tailscount + 1
Else
' 1 means heads is up, so display the heads
' image and hide the tails image.
picHeads.Visible = True
picTails.Visible = False
headscount = headscount + 1
End if
Next
lblHeads.Text = headscount
lblTails.Text = tailscount
End Sub