Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > invalid picture when image not selected in file list box


Reply
 
Thread Tools Display Modes
  #1  
Old 05-10-2007, 07:26 AM
dgallsop dgallsop is offline
Newcomer
 
Join Date: Apr 2007
Posts: 16
Unhappy invalid picture when image not selected in file list box


When I click through the directory and file list boxes and find an image, it displays in an imagebox I have setup.

But if I click anything other than an image it comes up the error 'Invalid picture' how can I put in a message box saying 'not an image' instead of this VB error?

My code is: -

Code:
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub File1_Click()
Image1.Picture = LoadPicture(File1.Path & "\" & File1.FileName)
End Sub
Reply With Quote
  #2  
Old 05-10-2007, 08:11 AM
Diurnal Diurnal is offline
Enthusiast

Retired Leader
* Expert *
 
Join Date: Apr 2002
Location: Bellevue, WA.
Posts: 3,233
Default

You could include an error handler in the routine. You can capture the error number and deal with it with a message box to alert the user to choose another file. You can look at the tutorial on Error Handlers to get more information.
__________________
Marty

Try searching for an answer first.
Tag your code [vb][/vb] and be patient... everyone here is a volunteer.
Reply With Quote
  #3  
Old 05-10-2007, 03:14 PM
moa moa is offline
Contributor
 
Join Date: Oct 2006
Posts: 483
Default

Hello,

Or simply use the pattern Property of the FileListBox !... (it's done for that purpose and accepts multiple patterns....).
Have a glance at it in your MSDN (would certainly be a good idea).
Reply With Quote
  #4  
Old 05-11-2007, 06:27 AM
dgallsop dgallsop is offline
Newcomer
 
Join Date: Apr 2007
Posts: 16
Default

thanks for the help, works great now with the pattern property.
Reply With Quote
  #5  
Old 05-14-2007, 09:39 PM
HoseHead78's Avatar
HoseHead78 HoseHead78 is offline
Centurion
 
Join Date: Oct 2003
Location: So. Cali
Posts: 113
Default

By any chance, would you tell me what formats your viewing?

Are you viewing PCX files? If so how are you vieing them?

Dont mean to piggyback on this post....
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->