how to dislay alternate image

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2008
Posts: 8
Reputation: showstopper2007 is an unknown quantity at this point 
Solved Threads: 0
showstopper2007 showstopper2007 is offline Offline
Newbie Poster

how to dislay alternate image

 
0
  #1
Sep 11th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: how to dislay alternate image

 
0
  #2
Sep 11th, 2008
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim basePath as String
  2. Dim filename as String
  3. Dim ext as String
  4. ext = ".jpg"
  5.  
  6. basePath = "C:\Images\"
  7. filename = Text3.Text
  8. filename = filename & ext
  9.  
  10. Dim oFile As New Scripting.FileSystemObject
  11. FileExists = oFile.FileExists(basePath & filename + ext)
  12.  
  13. If(!FileExists)
  14. filename = "mypic" + ext
  15. End If
  16.  
  17. Image1.Picture = LoadPicture(basepath & filename)
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 51
Reputation: Drycola is an unknown quantity at this point 
Solved Threads: 6
Drycola's Avatar
Drycola Drycola is offline Offline
Junior Poster in Training

Re: how to dislay alternate image

 
0
  #3
Sep 12th, 2008
Originally Posted by dickersonka View Post
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. If(!FileExists)
I'm not sure but ...
IS THIS VB6 ???????????
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: how to dislay alternate image

 
0
  #4
Sep 12th, 2008
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
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2. If Not (oFile.FileExists(basePath & filename + ext)) Then
  3. filename = "mypic" + ext
  4. End If
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 8
Reputation: showstopper2007 is an unknown quantity at this point 
Solved Threads: 0
showstopper2007 showstopper2007 is offline Offline
Newbie Poster

Re: how to dislay alternate image

 
0
  #5
Sep 12th, 2008
Dim oFile As New Scripting.FileSystemObject

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

plz help me with this...ASAP
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: how to dislay alternate image

 
0
  #6
Sep 12th, 2008
add reference to scrrun.dll
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 8
Reputation: showstopper2007 is an unknown quantity at this point 
Solved Threads: 0
showstopper2007 showstopper2007 is offline Offline
Newbie Poster

Re: how to dislay alternate image

 
0
  #7
Sep 12th, 2008
i really dont knw how to reference to scrrun.dll

plz tell me how it is done
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: how to dislay alternate image

 
0
  #8
Sep 12th, 2008
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 8
Reputation: showstopper2007 is an unknown quantity at this point 
Solved Threads: 0
showstopper2007 showstopper2007 is offline Offline
Newbie Poster

Re: how to dislay alternate image

 
0
  #9
Sep 12th, 2008
thanks a lot...
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 8
Reputation: showstopper2007 is an unknown quantity at this point 
Solved Threads: 0
showstopper2007 showstopper2007 is offline Offline
Newbie Poster

Re: how to dislay alternate image

 
0
  #10
Sep 12th, 2008
sumting is wrong with the code..it not working ...pls recheck the code
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC