this is my first project n i need help in displaying images in imagebox

this is the code to display the code which i am using to display images in imagebox

Image1.Picture = LoadPicture("C:\images\" & Text3.Text & ".jpg") '<<this works fine>>

in the above code the location is C:\images\ , the file name will be the value of text3

but in case if the image with the filename<<value of text 3>> is nt found in C:\images\

i want to display an alternate image whose name is "mypic" and is located in C:\images\

what should be the code??
plz help ASAP

9 Years
Discussion Span
Last Post by dickersonka
Dim basePath as String
Dim filename as String
Dim ext as String
ext = ".jpg"

basePath = "C:\Images\"
filename = Text3.Text
filename = filename & ext

 Dim oFile As New Scripting.FileSystemObject
    FileExists = oFile.FileExists(basePath & filename + ext)

filename = "mypic" + ext
End If

Image1.Picture = LoadPicture(basepath & filename)

nice catch, got in a hurry and have been used to c# for a bit

you do need to add a reference to scrrun.dll

If Not (oFile.FileExists(basePath & filename + ext)) Then
filename = "mypic" + ext
End If

Dim oFile As New Scripting.FileSystemObject

when running it says " compile error: user -defined type not defined

plz help me with this...ASAP


sorry for the last post....it was my mistake that it wasnt working...no its working fine...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.