takowai Posted August 8, 2003 Posted August 8, 2003 I have a form which, when data is entered in certain textboxes, produces a file path to retrieve a .gif file for a picturebox. My problem is - how can I get a messagebox to say "File not found" if the file does not exist in that directory or if the data placed in the textboxes is incorrect thereby giving a wrong file path? Everything I try comes back with a debugging message. Help would be much appreciated. Thanks. Quote
Diablicolic Posted August 8, 2003 Posted August 8, 2003 This should solve your problem, just use Try and Catch, so if there is an error in the Try, then you can refer to the code in Catch, you shall see my son: 'This is where you enter the code to get the .gif that gives ya trouble Try Dim strPath As String strPath = "The path of the .gif I want to use.gif" PictureBox1 = PictureBox1.FromFile(strPath) Catch MessageBox.Show("That path is false") End Try Quote "Reality is fake, Dreams are for real"
takowai Posted August 8, 2003 Author Posted August 8, 2003 Thank you, it works perfectly. Will I ever understand all of this? I am enjoying the challenge but it gets so frustrating sometimes! Once again - thanks for your assistance Quote
Winston Posted August 8, 2003 Posted August 8, 2003 That is the sleezy method of doing it and if you're in for programming in .NET the right way you should make use of the namespaces that .NET provides this is the real way of doing it If System.IO.File.Exists(Me.txtPath.text) Then 'Returned file path is true then proceed on Me.Picture1.Image = PictureBox1.FromFile(Me.txtPath.text) Else 'If Returned file path is false then Prompt user MessageBox.Show("File Does not exist!", "File not found.", MessageBoxButtons.OK, MessageBoxIcon.Error) End If Quote
ThePentiumGuy Posted August 12, 2003 Posted August 12, 2003 Try using GDI+, GDI+ is a better way to display Graphics because it is faster Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.