473,657 Members | 2,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checking for reference file existance before use

Jm
Hi all

Im a bit of a newbie to VB.NET. Under vb6 if i used a class library DLL and
it wasnt available i could use the on error resume next to get past the code
that calls it and trap it afterwards and display a custom error messageor
move on. I was wondering if this is possible in VB.NET, it seems to just end
the program with a vb frameworkish error. Basically my code says:

Imports My_Project
.......
Dim MyProjectObj As New Project1

(Project1 being the class inside the My_Project namesapce)

Any help is greatly appreciated
Nov 21 '05 #1
6 1129
Jm wrote:
Hi all

Im a bit of a newbie to VB.NET. Under vb6 if i used a class library DLL and
it wasnt available i could use the on error resume next to get past the code
that calls it and trap it afterwards and display a custom error messageor
move on. I was wondering if this is possible in VB.NET, it seems to just end
the program with a vb frameworkish error. Basically my code says:

Imports My_Project
......
Dim MyProjectObj As New Project1

(Project1 being the class inside the My_Project namesapce)

Any help is greatly appreciated

..NET uses a try-catch method, so:

TRY
<insert critical code here>
CATCH ex as exception
MessageBox(ex.m essage)
FINALLY
<code here to wrap up things if you need to>
END TRY

--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #2
Jm

In addition to Rinze

For file existence you would not use error trapping.

Error trapping should be done with situation that you cannot know or test
before because they happens not under your control.

When your program is on the same drive as your program, than your disk is
working therefore this should be enough.

\\\
If Not file.exist(myfi le) then messagebox.show ("the file does not exist")
///

I hope this helps?

Cor

Jm" <ja*****@ihug.c om.au>
Hi all

Im a bit of a newbie to VB.NET. Under vb6 if i used a class library DLL
and
it wasnt available i could use the on error resume next to get past the
code
that calls it and trap it afterwards and display a custom error messageor
move on. I was wondering if this is possible in VB.NET, it seems to just
end
the program with a vb frameworkish error. Basically my code says:

Imports My_Project
......
Dim MyProjectObj As New Project1

(Project1 being the class inside the My_Project namesapce)

Any help is greatly appreciated

Nov 21 '05 #3
"Jm" <ja*****@ihug.c om.au> schrieb:
Im a bit of a newbie to VB.NET. Under vb6 if i used a class library DLL
and
it wasnt available i could use the on error resume next to get past the
code
that calls it and trap it afterwards and display a custom error messageor
move on. I was wondering if this is possible in VB.NET, it seems to just
end
the program with a vb frameworkish error. Basically my code says:


Does this error even occur when you use 'On Error Resume Next'?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4
Jm
Hi All

Ok i looked at all replys, thanks for sending them so quick. To answer the
last one, when i use the on error resume next it still ends the program. I
didnt mention earlier that this program is a service. As a bit of further
background what im trying to trap is a dll file used for licesneing control,
basically i will use the dim statement to reference it and under vb6 this
was fine because i could on error resume next. But under .NET i did try the
following:

Try

Dim MyObj As New Project1

Catch ex As Exception

MsgBox("LicFail ", MsgBoxStyle.Cri tical, "LicFail")

Finally

End

End Try

But it does the same as before, and doesnt disaply the message box. Is it
possible to do what i used to under Vb6 in .Net ? Many thanks all

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:#3******** ******@TK2MSFTN GP15.phx.gbl...
"Jm" <ja*****@ihug.c om.au> schrieb:
Im a bit of a newbie to VB.NET. Under vb6 if i used a class library DLL
and
it wasnt available i could use the on error resume next to get past the
code
that calls it and trap it afterwards and display a custom error messageor move on. I was wondering if this is possible in VB.NET, it seems to just
end
the program with a vb frameworkish error. Basically my code says:


Does this error even occur when you use 'On Error Resume Next'?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5
"Jm" <ja*****@ihug.c om.au> schrieb:
Dim MyObj As New Project1

Catch ex As Exception

MsgBox("LicFail ", MsgBoxStyle.Cri tical, "LicFail")

Finally

End

End Try

But it does the same as before, and doesnt disaply the message box. Is it
possible to do what i used to under Vb6 in .Net ? Many thanks all


What's 'Project1'? A class in your library?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #6
Jm
Yes, the dim statement works fine as long as you can access the dll file,
but when i purposely remove it is when i have the issue, which i could get
around under vb6

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:eE******** ******@TK2MSFTN GP10.phx.gbl...
"Jm" <ja*****@ihug.c om.au> schrieb:
Dim MyObj As New Project1

Catch ex As Exception

MsgBox("LicFail ", MsgBoxStyle.Cri tical, "LicFail")

Finally

End

End Try

But it does the same as before, and doesnt disaply the message box. Is it possible to do what i used to under Vb6 in .Net ? Many thanks all


What's 'Project1'? A class in your library?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2058
by: Cherrish Vaidiyan | last post by:
hello scholars, i am just learning PHP. i have a small requirement in urgency.i want to create a functionality of archiving in which a user can upload any file through a browser to a location. but in that functionality. I want to solve a small error in my program.The case is explained below.... If i type the path,currently my program dont check for existance of the file.ie; even if the file exist or not, the results appears as
5
11062
by: Uzi G. | last post by:
Hi, We have a JSP website intended for viewing with IE 5 (and above) On a certain jsp page, there are few span objects (<SPAN ID="name">text</SPAN>), which are created dynamically. The spans share the same ID, so we are able to reference them as an array, in the javascript code : for example:
2
1405
by: William Kossack | last post by:
I'm trying to write a program in cold fusion to check the existance of fields and data types according to requirements I was looking at the syscolumns table for some of this information but I've discovered that in my playing (creating and deleting tables) thre are multiple entries for a field that is in table that is created then deleted then created again. Is this a problem? Is there a better way to get at the information ie the...
4
1397
by: Lambuz | last post by:
Is there any way to check the existance of a window by the name ? I'm using this code: window.open("http://www.google.com",'targetWin1') If I open a window using previous code without getting immediatly return value of open method, can I get it in a second moment ? For example using the value of param sName of open method ? regards
5
5782
by: A.M | last post by:
Hi, To check if QueryString contains a key I compaire it with null like this code: if (Request.QueryString!=null) { Label1.Text= Request.QueryString; } else
2
1165
by: tshad | last post by:
I was looking at different ways of doing the same thing and at the moment was looking at the use of "is" and "=", as I have at times found that I will do something like if something = 0 and will get an error that says I can't use "=" (or <>) in this case case I must use "is" ( or not something is). I am trying to find out when this is the case - when I can use the "=" and when I have to use "is.
6
3667
by: Juggler | last post by:
Hi all I've written a program in VB.NET that allows the user to build quotes for installing shower enclosures. As part of the program, I've included a blank Access database. I've provided them with an interface where they can add their own clients to the database When the user upgrades to a newer version of my program, I don't want the installer to overwrite the Access database file with my blank one again. How can I tell VB.NET to check...
3
1018
by: borec | last post by:
how do I check if a file with a specific name exists in a folder on my computer. Im working on a macro in MSWord. Please help. Some suggested: If System.IO.File.Exists(fileToOpen) = True Then ... Else ...
6
1355
by: Andy B | last post by:
How do you check to see if a certain folder exists? I also need to know how to check for the existance of a certain sql server database table.
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8726
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7320
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1604
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.