Public Class Form1

Dim coin As New Random
Dim heads, tails, outcome As Integer
Dim totals As Double

Dim frequency As Decimal

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

heads = 0
tails = 0
totals = 0

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


If Flip() Then
heads = heads + 1
THeads.Text = heads
Else
tails = tails + 1
Ttails.Text = tails
End If

totals = totals + 1

Ttotal.Text = totals

End Sub

Function Flip() As Boolean
Return CBool(coin.Next(0, 2))

End Function

End Class


I have two images in my Resource file - coin1.jpg and coin2.jpg

one for heads and one for tails.

How do make them display along with the results of the toss

when heads comes up a head appears

when tails comes up a tail appears.

HELP!!!

Add this to your loop.

Imports System.Drawing

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Flip() Then
            heads = heads + 1
            THeads.Text = heads
            PictureBox1.Image = New Bitmap("c:\coin1.jpg")
        Else
            tails = tails + 1
            Ttails.Text = tails
            PictureBox1.Image = New Bitmap("c:\coin2.jpg")
        End If

    End Sub
End Class

Public Class Form1

Dim coin As New Random
Dim heads, tails, outcome As Integer
Dim totals As Double

Dim frequency As Decimal

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

heads = 0
tails = 0
totals = 0

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


If Flip() Then
heads = heads + 1
THeads.Text = heads
coinPictureBox1.Image = New Bitmap("c:\coin1.jpg")
Else
tails = tails + 1
Ttails.Text = tails
coinPictureBox1.Image = New Bitmap("c:\coin2.jpg")
End If

totals = totals + 1

Ttotal.Text = totals

End Sub

Function Flip() As Boolean
Return CBool(coin.Next(0, 2))

End Function

End Class


Adding this doesn't do it. don't I need a DisplayCoin() subroutine or something I am so mixed up Help!!!!!

This is what I ran and it worked fine.

Public Class Form1
    Dim heads As Integer = 0
    Dim tails As Integer = 0
    Dim totals As Integer = 0
    Dim coin As New Random

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Flip() Then
            heads = heads + 1
            THeads.Text = heads.ToString & ""
            coinPictureBox1.Image = New Bitmap("c:\graphics\refresh.jpg")
        Else
            tails = tails + 1
            Ttails.Text = tails
            coinPictureBox1.Image = New Bitmap("c:\graphics\stop.jpg")
        End If
        totals = totals + 1
        Ttotal.Text = totals
    End Sub

    Function Flip() As Boolean
        Return CBool(coin.Next(0, 2))
    End Function

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Randomize()
    End Sub
End Class

Now I didn't have your graphics so I just picked two from my images. All my graphics is in one folder called "graphics" so you will have to change the path to your graphics.

thank you this worked just fine

thank you this worked just find

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.