Jag har en On Error. Du kan göra såhär. Kanske på detta viset...Öppna bild, men tomt.
Men finns det något sätt att titta på värdet som hämtas?
Picture1 = LoadPicture("bild.bmp")
If Picture1 = Null Then MsgBox "Null!"
If Picture1 <> Null Then MsgBox "Pic!"
Tacksam för hjälp! :-)Sv: Öppna bild, men tomt.
Private Sub Command1_Click()
Dim pic As StdPicture
Set pic = GetPicture("Test.bmp")
If pic Is Nothing Then
'Tömmer bilden
Picture1.Picture = LoadPicture("")
Else
Picture1.Picture = pic
End If
End Sub
Private Function GetPicture(FileName As String) As StdPicture
On Error Resume Next
Set GetPicture = LoadPicture(FileName)
End Function
Om du åkså vill visa felet som uppstod kan du skriva:
Private Function GetPicture(FileName As String) As StdPicture
On Error GoTo GetPicture_Err
Set GetPicture = LoadPicture(FileName)
Exit Function
GetPicture_Err:
MsgBox Err.Description, vbCritical
End FunctionSv: Öppna bild, men tomt.
Sample Code ===================================
On Error Resume Next
Set Picture1.Picture = LoadPicture("c:\apa.bmp")
If Picture1.Picture = 0 Then
MsgBox "Pic Not Loaded"
Else
MsgBox "Pic Loaded"
End If
On Error GoTo 0
Sample Code ===================================
/peterh