Results 1 to 4 of 4

Thread: Adding images to picture box in runtime?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    20

    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

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: Adding images to picture box in runtime?

    VB Code:
    1. Private Sub Form_Click ()
    2.    Dim Msg as String   ' Declare variables.
    3.    On Error Resume Next   ' Set up error handling.
    4.    Height = 3990
    5.    Width = 4890   ' Set height and width.
    6.    Picture1.Picture = LoadPicture("PAPER.CUR", vbLPCustom, vbLPColor, 32, 32)   ' Load cursor.
    7.    If Err Then
    8.       Msg = "Couldn't find the .cur file."
    9.       MsgBox Msg   ' Display error message.
    10.       Exit Sub   ' Quit if error occurs.
    11.    End If
    12.    Msg = "Choose OK to clear the bitmap from the picturebox."
    13.    MsgBox Msg
    14.    Picture1.Picture = LoadPicture()   'Clear the picturebox.
    15. End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    20

    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

  4. #4
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: Adding images to picture box in runtime?

    Quote 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:
    1. Private Sub Command1_Click()
    2. On Error Resume Next
    3.    With CommonDialog1
    4.            .CancelError=True
    5.            .Filter = "All Images|*.bmp;*.jpg;*.gif|All Files|*.*"
    6.            .ShowOpen
    7.             Picture1.Picture = LoadPicture(commondialog1.FileName)
    8.    End With
    9. Exit Sub
    10. If Err.Number = 32755 Then Exit Sub
    11. 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
  •  



Click Here to Expand Forum to Full Width