VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



How to add picture using imagebox and picture box

by king (24 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 26th January 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)

How to add picture using imagebox and picture box

API Declarations


you will need two buttons , one picture box or image box control anything you want to place on a form and a common dialog box control


Rate How to add picture using imagebox and picture box



you can choose any control you want whether you want the picture box control or the image box control
step2
how to browse the picture from the commondialog box to the picture box control
write this code on the browse button . Remember to change the of the commondialogbox control name it cd.
Private Sub menuopen_Click()
On Error Resume Next
On Error GoTo invalid:
  cd.Filter = " Gif files (*.gif)|*gif| Jpeg files (*.jpg)|*.jpg| Bmp files (*.bmp)|*.bmp| All files (*'*)|*.*|"
  cd.Action = 1
    If InStr(cd.Filter, ".jpg") Or InStr(cd.Filter, ".gif") Or InStr(cd.Filter, ".bmp") Or InStr(cd.Filter, ".ico") Or InStr(cd.Filter, ".dib") Or InStr(cd.FileName, ".wmf") Or InStr(cd.FileName, ".emf") Then
      Picture1.Picture = LoadPicture(cd.FileName)

    Else
invalid:
      MsgBox " This file is not supported by pic view make sure that u have choose a correct picture file " & cd.FileName & " doesnt seem to be a valid picture file ", vbExclamation
      End If
      End Sub
copy this code as it is on the browse button click event

step 3
how to remove the picture from the picture box control
write this code on the remove button click event
Private Sub menuremove_Click()
On Error Resume Next
Picture1.Picture = LoadPicture()
End Sub

thats it if you have any questions you can ask me on my email address [email protected]



Download this snippet    Add to My Saved Code

How to add picture using imagebox and picture box Comments

No comments have been posted about How to add picture using imagebox and picture box. Why not be the first to post a comment about How to add picture using imagebox and picture box.

Post your comment

Subject:
Message:
0/1000 characters