| | |
VB 2008 help in displaying images
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2009
Posts: 8
Reputation:
Solved Threads: 0
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!!!
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!!!
•
•
Join Date: Dec 2002
Posts: 461
Reputation:
Solved Threads: 56
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.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
•
•
Join Date: Mar 2009
Posts: 8
Reputation:
Solved Threads: 0
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!!!!!
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!!!!!
•
•
Join Date: Dec 2002
Posts: 461
Reputation:
Solved Threads: 56
This is what I ran and it worked fine.
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.
VB.NET Syntax (Toggle Plain Text)
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
Wayne
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
![]() |
Similar Threads
- PHP 5 on Tomcat 5.5 (Windows NT / 2000 / XP)
- PHP and Tomcat (PHP)
- Firefox Compatibility help with script (JavaScript / DHTML / AJAX)
Other Threads in the VB.NET Forum
- Previous Thread: Dropdownlist Multiview
- Next Thread: VB Help
| Thread Tools | Search this Thread |
.net .net2008 30minutes 2005 2008 access account arithmetic array basic bing button buttons center check code combobox component connectionstring crystalreport data database databasesearch datagrid datagridview date design dissertation dissertations dropdownlist excel fade file-dialog filter folder ftp generatetags google gridview hardcopy images input insert intel internet mobile monitor ms net networking objects output panel passingparameters peertopeervideostreaming picturebox picturebox1 port position print printing problem problemwithinstallation project save searchbox searchvb.net select serial shutdown soap survey table tcp temperature text textbox timer timespan toolbox trim update updown user vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf year





