VB 2008 help in displaying images

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2009
Posts: 8
Reputation: rickbill is an unknown quantity at this point 
Solved Threads: 0
rickbill rickbill is offline Offline
Newbie Poster

VB 2008 help in displaying images

 
0
  #1
Mar 12th, 2009
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!!!
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: VB 2008 help in displaying images

 
0
  #2
Mar 12th, 2009
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
Wayne

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 8
Reputation: rickbill is an unknown quantity at this point 
Solved Threads: 0
rickbill rickbill is offline Offline
Newbie Poster

Re: VB 2008 help in displaying images

 
0
  #3
Mar 12th, 2009
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!!!!!
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: VB 2008 help in displaying images

 
0
  #4
Mar 13th, 2009
This is what I ran and it worked fine.
  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.
Wayne

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 8
Reputation: rickbill is an unknown quantity at this point 
Solved Threads: 0
rickbill rickbill is offline Offline
Newbie Poster

Re: VB 2008 help in displaying images

 
0
  #5
Mar 13th, 2009
thank you this worked just fine
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 8
Reputation: rickbill is an unknown quantity at this point 
Solved Threads: 0
rickbill rickbill is offline Offline
Newbie Poster

Re: VB 2008 help in displaying images

 
0
  #6
Mar 13th, 2009
thank you this worked just find
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC