how to provide customized error message 
Author Message
 how to provide customized error message

i'm using the code below to open a text file.  The user provides the
path & folder... but if they type in something incorrect, IE will say
the page cannot be displayed... Microsoft VBScript runtime
(0x800A004C).  It breaks on the OpenTextFile function.

How can i trap this error & give them a better error message, like "hey
put in a valid path..."?  My code is the following:

Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set textStream  = fso.OpenTextFile(strPath + strFolder
+ "\bsumaoff.txt", ForReading)

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 18 May 2003 03:00:00 GMT  
 how to provide customized error message
on error goto errtxtStream

you code

errResume:
exit sub/funtion...etc

errtxtStream:
errNumber = what ever it is...
If err.number = errNumber then
    blah blah
end if


Quote:
> i'm using the code below to open a text file.  The user provides the
> path & folder... but if they type in something incorrect, IE will say
> the page cannot be displayed... Microsoft VBScript runtime
> (0x800A004C).  It breaks on the OpenTextFile function.

> How can i trap this error & give them a better error message, like "hey
> put in a valid path..."?  My code is the following:

> Const ForReading = 1
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set textStream = fso.OpenTextFile(strPath + strFolder
> + "\bsumaoff.txt", ForReading)

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sun, 18 May 2003 03:00:00 GMT  
 how to provide customized error message
Use On Error Resume Next, try the code and check Err.Number for non-zero.

On Error Resume Next
...
...code with potential for error
...
if Err.Number <> 0 Then
    On Error GoTo 0
    ...
    ...it failed - do something to inform user
    ...
    Response.End
End If
On Error GoTo 0
...
...it worked...
...

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> i'm using the code below to open a text file.  The user provides the
> path & folder... but if they type in something incorrect, IE will say
> the page cannot be displayed... Microsoft VBScript runtime
> (0x800A004C).  It breaks on the OpenTextFile function.

> How can i trap this error & give them a better error message, like "hey
> put in a valid path..."?  My code is the following:

> Const ForReading = 1
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set textStream = fso.OpenTextFile(strPath + strFolder
> + "\bsumaoff.txt", ForReading)

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sun, 18 May 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. customizing error messages

2. Using customized PPD files to customize Windows printer properties defaults

3. customize application for retreiving nntp messages

4. how do I use a customized mail message?

5. Customizing Workgroup Messages

6. Setup Wizard and popup messages customize [Q]

7. Customizing the OLE "Server Busy" message

8. Post a customized message to a datagrid

9. Customized Message Box

10. gswin32 provides nothing but errors

11. Setup error - can anyone provide info?

12. Changing server name and location provides error

 

 
Powered by phpBB® Forum Software