| | |
Upload picture from file
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Feb 2008
Posts: 9
Reputation:
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:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
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 Class
Thank you
Last edited by Tekmaven; Jul 20th, 2008 at 3: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 4:39 pm.
-- Martín
![]() |
Similar Threads
- 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
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





