Visual Basic Reference

LoadPicture Function Example

This example uses the LoadPicture function to load a picture into a PictureBox control and to clear the picture from the control. To try this example, add a PictureBox control to a Form object, paste the code into the Declarations section of the Form, and then run the example and click the Form.

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