LoadPicture_Safe

Loads an image into VBA image control without knowing its extension
If file not found, loads a default image [From 7Bricks]
Also, loads an image during that process to let user know that we are working
Used for Jpg, png, jpeg, bmp and gif

CodeFunctionName
What is this?

Public

Tested

Original Work
Sub LoadPicture_Safe(FullNameWithoutEXT, ImageControl As Image)
' Loads an image without knowing its extention
' If file not found, loads a default image
' Used in 7Bricks
' ShData.Image1 has the default image (image not found description maybe)
' ShData.Image2 has "Loading..." image
'
ImageControl.Picture = ShData.Image2.Picture ' loading image
doevents
fin = FullNameWithoutEXT & ".jpg"
PicFound = False
PicFound = IsThere1(fin, True, True)
DoEvents
If Not PicFound Then
fin = FullNameWithoutEXT & ".png"
PicFound = IsThere1(fin, True, True)
If Not PicFound Then
fin = FullNameWithoutEXT & ".bmp"
PicFound = IsThere1(fin, True, True)
If Not PicFound Then
fin = FullNameWithoutEXT & ".gif"
PicFound = IsThere1(fin, True, True)
If Not PicFound Then
fin=FullNameWithoutEXT & ".jpeg"
PicFound = IsThere1(fin, True, True)
End if
End If
End If
End If
If PicFound Then
ImageControl.Picture = LoadPicture(fin)
DoEvents
Else
ImageControl.Picture = ShData.Image1.Picture
End If
End Sub

FullNameWithoutEXT, ImageControl

Views 3,290

Downloads 1,297

CodeID
DB ID