473,506 Members | 13,088 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 1117
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.message)
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(myfile) then messagebox.show("the file does not exist")
///

I hope this helps?

Cor

Jm" <ja*****@ihug.com.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.com.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.Critical, "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**************@TK2MSFTNGP15.phx.gbl...
"Jm" <ja*****@ihug.com.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.com.au> schrieb:
Dim MyObj As New Project1

Catch ex As Exception

MsgBox("LicFail", MsgBoxStyle.Critical, "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**************@TK2MSFTNGP10.phx.gbl...
"Jm" <ja*****@ihug.com.au> schrieb:
Dim MyObj As New Project1

Catch ex As Exception

MsgBox("LicFail", MsgBoxStyle.Critical, "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
2036
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....
5
11060
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...
2
1395
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...
4
1388
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...
5
5775
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
1158
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...
6
3656
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...
3
1014
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...
6
1352
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
7220
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,...
0
7105
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...
0
7371
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...
1
7023
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7479
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4702
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...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1534
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
410
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...

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.