Results 1 to 3 of 3

Thread: Super easy question

  1. #1

    Thread Starter
    Hyperactive Member dflw's Avatar
    Join Date
    Apr 2001
    Location
    ct, usa
    Posts
    412

    Super easy question

    Hi,

    I have a picturebox and a command button titled browse. How do I make it so when i click on the cmd button, it brings up the dialogue box where i can select a file? Also, when I select a .bmp image and click ok, how do i load it into the picture box?

    thanks in advacne
    Visual Basic 6, HTML, JavaScript, learning C++

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Add a reference to the MS Common Dialog Control, add one to the form, and use something like this:

    VB Code:
    1. 'CD1 = CommonDialog
    2. Private Sub cmdBrowse_Click()
    3.   CD1.Filter = "*.bmp"
    4.   CD1.ShowOpen
    5.  
    6.   Picture1.Picture = LoadPicture(CD1.FileName)
    7. End Sub

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Lively Member Ali G's Avatar
    Join Date
    Nov 2001
    Location
    Staines
    Posts
    120
    like dis, aye
    VB Code:
    1. CommonDialog1.Filter = "Bitmap (*.bmp)|*.bmp"
    2. CommonDialog1.ShowOpen
    3.  
    4. If Len(CommonDialog1.FileName) > 0 Then
    5.     Picture1.Picture = LoadPicture(CommonDialog1.FileName)
    6. End If

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