VB語言中LoadPicture函數用法示例:
本例使用 LoadPicture 函數將圖片加載到窗體的 PictureBox 控件並從控件上清除掉該圖片。
要試用此例,將 PictureBox 控件添加入 Form 對象,然后將以下代碼粘貼到 Form 的聲明部分,然后運行此例,單擊 Form 。
Private Sub Form_Click()
Dim Msg As String ' 聲明變量。
On Error Resume Next ' 設置錯誤句柄。
Height = 3990
Width = 4890 ' 設置高度和寬度。
Picture1.Picture = LoadPicture("C:\Windows\Web\Wallpaper\Windows\img0.jpg", vbLPCustom, vbLPColor, 32, 32)
If Err Then
Msg = "Couldn't find the .cur file."
MsgBox Msg ' 顯示錯誤消息。
Exit Sub ' 如果發生錯誤則退出。
End If
Msg = "Choose OK to clear the bitmap from the form."
MsgBox Msg
Picture1.Picture = LoadPicture() '清除 picturebox。
End Sub
LoadPicture 函數,將圖形載入到窗體的 Picture 屬性、PictureBox 控件或 Image 控件。