|
-
Jan 17th, 2004, 08:05 PM
#1
Thread Starter
Member
Coding Issues
I am new at Visual Basic. Im in high school and decided to take on programming as an elective. Its turned into my hobby. I need help though. I have a picture box. I want it so that if the user clicks on the picture box, the picture changes. What is the code for that? I tried this
Code:
Private Sub PictureBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Box1.Click
Me.PictureBox.Image = location of saved image on harddrive
End Sub
-
Jan 17th, 2004, 08:08 PM
#2
Hyperactive Member
from memory:
VB Code:
Me.PictureBox.Image = Image.FromFile("Path")
Visual Baisc 6 (SP5)
Windows Xp
-
Jan 17th, 2004, 11:02 PM
#3
Thread Starter
Member
Thanks, that helps. Im such a newbie
-
Jan 17th, 2004, 11:21 PM
#4
Originally posted by andrew5578
Thanks, that helps. Im such a newbie
one issue though, although you and most people probably dont care about it: if you load the image that way, the image file will be locked until your program unloads, or until you dispose the image. The only simple way that I know to get around this is the get a copy of the loaded image and dispose the one that you loaded from file so the file would get unlocked:
VB Code:
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Dim imgSrc As Image = Image.FromFile("C:\txtr.bmp")
PictureBox1.Image = New Bitmap(imgSrc)
imgSrc.Dispose()
End Sub
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|