•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 426,011 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,596 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 751 | Replies: 3 | Solved
![]() |
•
•
Join Date: Feb 2008
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
Hi!
I'm trying to make a coin toss program using a random generator, but i'm not sure how to upload the image of the heads and tails from its file on my PC. Image names are Tails.gif and Heads.gif . Here's the code so far:
Thank you
I'm trying to make a coin toss program using a random generator, but i'm not sure how to upload the image of the heads and tails from its file on my PC. Image names are Tails.gif and Heads.gif . Here's the code so far:
Public Class Form1
Dim headCount As Integer
Dim tailCount As Integer
Dim choice As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblHeadCt.Text = "Heads: " & Str(headCount)
lblTailCt.Text = "Heads: " & Str(tailCount)
End Sub
Private Sub cmdFlip_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFlip.Click
Randomize()
choice = Int(Rnd() * 2)
If choice = 0 Then
headCount = headCount + 1
imgCoin = Image.FromFile()
Else
tailCount = tailCount + 1
imgCoin =
End If
End Sub
End ClassThank you
Last edited by Tekmaven : Jul 20th, 2008 at 2:57 pm. Reason: Code tags
Hi,
First, this is not VB6 code. It is VB.Net.
To load an image, you must code:
Then, if you want to put the image in a PictureBox, you must write:
Hope it helps
First, this is not VB6 code. It is VB.Net.
To load an image, you must code:
VBNET Syntax (Toggle Plain Text)
Dim coinImage As Image Dim imagePath As String = "" If choice = 0 Then headCount = headCount + 1 imagePath = "Heads.gif" Else tailCount = tailCount + 1 imagePath = "Tails.gif" End If ' Here you have your image loaded in coinImage coinImage = New Bitmap(imagePath)
Then, if you want to put the image in a PictureBox, you must write:
VBNET Syntax (Toggle Plain Text)
PictureBox1.Image = coinImage
Hope it helps
Last edited by dmf1978 : Jul 21st, 2008 at 3:39 pm.
-- Martín
![]() |
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- how to put uploading picture to the application database. (Visual Basic 4 / 5 / 6)
- Problems with file upload (PHP)
- Get data out of excel file stored as an image (MS SQL)
- Uploading progress (PHP)
- Allow User To Upload A Picture (JSP)
- upload files hlp (PHP)
- When Users Upload *.txt file, i will get Total Points ,Points Per Game ,etc... (PHP)
- little picture on the browser tab (PHP)
- uploading a picture (PHP)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Difficulty in reading data thru Com port
- Next Thread: Bind ListBox to ADODB.Recordset


Linear Mode