943,548 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1965
  • VB.NET RSS
Mar 12th, 2009
0

VB 2008 help in displaying images

Expand Post »
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!!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rickbill is offline Offline
8 posts
since Mar 2009
Mar 12th, 2009
0

Re: VB 2008 help in displaying images

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
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002
Mar 12th, 2009
0

Re: VB 2008 help in displaying images

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!!!!!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rickbill is offline Offline
8 posts
since Mar 2009
Mar 13th, 2009
0

Re: VB 2008 help in displaying images

This is what I ran and it worked fine.
VB.NET Syntax (Toggle Plain Text)
  1. Public Class Form1
  2. Dim heads As Integer = 0
  3. Dim tails As Integer = 0
  4. Dim totals As Integer = 0
  5. Dim coin As New Random
  6.  
  7. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  8. If Flip() Then
  9. heads = heads + 1
  10. THeads.Text = heads.ToString & ""
  11. coinPictureBox1.Image = New Bitmap("c:\graphics\refresh.jpg")
  12. Else
  13. tails = tails + 1
  14. Ttails.Text = tails
  15. coinPictureBox1.Image = New Bitmap("c:\graphics\stop.jpg")
  16. End If
  17. totals = totals + 1
  18. Ttotal.Text = totals
  19. End Sub
  20.  
  21. Function Flip() As Boolean
  22. Return CBool(coin.Next(0, 2))
  23. End Function
  24.  
  25. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  26. Randomize()
  27. End Sub
  28. 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.
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002
Mar 13th, 2009
0

Re: VB 2008 help in displaying images

thank you this worked just fine
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rickbill is offline Offline
8 posts
since Mar 2009
Mar 13th, 2009
0

Re: VB 2008 help in displaying images

thank you this worked just find
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rickbill is offline Offline
8 posts
since Mar 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Dropdownlist Multiview
Next Thread in VB.NET Forum Timeline: VB Help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC