This is what I have so far. I need to let the program toss the coind each time the user presses the Toss button. Count the number of times each side of the coin appears. and display the results using heads and tails images. I am stuck


Public Class Form1
Dim randomObject As New Random()

Dim heads As Integer
Dim tails As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim heads As Integer = 0
Dim tails As Integer = 0

For counter = 1 To 100
If Flip() Then

heads += 1
Else


tails += 1
End If
TextBox1.Text = heads


TextBox2.Text = tails


Next


End Sub


Function Flip() As Boolean

Dim toss As Boolean

If (randomObject.Next(1, 100) Mod 2) = 0 Then
toss = True


Else

toss = False

End If

Return toss


End Function

Sub DisplayCoin(ByVal PictureBox As PictureBox, ByVal face As Integer)

Dim pictureResource = My.Resources.ResourceManager.GetObject( _
String.Format(face))

PictureBox1.Image = CType(pictureResource, Image)
PictureBox2.Image = CType(pictureResource, Image)

End Sub

Hmmm I only did this project in python, but if you create two images ( one for heads and one for tails) then link them to the results via a boolean, this should help. If you can't find out how to do this...google it.
Hope this helped and have fun

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.