-
Apr 20th, 2005, 03:38 AM
#1
Thread Starter
Junior Member
Adding images to picture box in runtime?
Good Morning,
Would you be able to help, i am wanting to add an image to my vb program during runtime, via a browse button which will place the chosen image in a picturebox.
Thanks,ourplace 85
-
Apr 20th, 2005, 03:40 AM
#2
Re: Adding images to picture box in runtime?
VB Code:
Private Sub Form_Click ()
Dim Msg as String ' Declare variables.
On Error Resume Next ' Set up error handling.
Height = 3990
Width = 4890 ' Set height and width.
Picture1.Picture = LoadPicture("PAPER.CUR", vbLPCustom, vbLPColor, 32, 32) ' Load cursor.
If Err Then
Msg = "Couldn't find the .cur file."
MsgBox Msg ' Display error message.
Exit Sub ' Quit if error occurs.
End If
Msg = "Choose OK to clear the bitmap from the picturebox."
MsgBox Msg
Picture1.Picture = LoadPicture() 'Clear the picturebox.
End Sub
-
Apr 20th, 2005, 03:45 AM
#3
Thread Starter
Junior Member
Re: Adding images to picture box in runtime?
would you have another piece of code that enables the user to browse a folder and then select an image of there choice.
thanks
-
Apr 20th, 2005, 04:55 AM
#4
Frenzied Member
Re: Adding images to picture box in runtime?
Originally Posted by ourplace85
would you have another piece of code that enables the user to browse a folder and then select an image of there choice.
thanks
You are in need of using Common Dialog Control for this...
Goto Project->Components, Find Microsoft Common Dialog Control 6.0, add it to the project... then
VB Code:
Private Sub Command1_Click()
On Error Resume Next
With CommonDialog1
.CancelError=True
.Filter = "All Images|*.bmp;*.jpg;*.gif|All Files|*.*"
.ShowOpen
Picture1.Picture = LoadPicture(commondialog1.FileName)
End With
Exit Sub
If Err.Number = 32755 Then Exit Sub
End Sub
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
|