LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default Why the heck doesn't this work?

On Tuesday, August 13, 2019 at 11:02:48 AM UTC-7, GS wrote:

You could dump the file into a string variable before splitting
the lines into


Yes, I agree I can do some basic checks to see if the file is
not empty or if the file does not exist. However, if anything
else crashes in my function, couldn't I just use the ON ERROR GOTO
statement?


Most all procedures *should have* an error handler built into them as a matter
of 'best practice'. Example:

Sub DoThis()
'Brief description of process intent

'Declare variables/constants

'Start code
'When it reaches a potential sect to raise an error...
On Error GoTo ErrExit '//label specifying jump-to position
'Potential code to raise error


ErrExit:
'Code to handle the error (and optionally Resume execution
'Code to cleanup objects before Exiting procedure
'Code to notify user of the error and/or request an action to take
'Function value to return
' ie: FunctionName = (Err = 0) if Boolean
' otherwise a null or default value

End Sub

Error handling is an elaborate convention on its own which entire book chapters
are dedicated for. You can dismiss the error, display a message to the user,
and/or write the error to an error.log file using a central error handling
system in your VBA projects.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How the heck? Dave Excel Worksheet Functions 6 April 8th 08 03:34 AM
trace dependent tool doesn't work but trace precendent doesn't marnie Excel Discussion (Misc queries) 2 May 24th 07 12:26 PM
What the heck is wrong here? [email protected] Excel Programming 1 January 5th 07 06:20 PM
macro doesn't properly record AutoSum (and SendKeys doesn't work) crimsonkng Excel Programming 2 November 21st 06 02:11 PM
Shell Doesn't Work With UNC - Can't Get ShellExecute to Work Either [email protected] Excel Programming 1 September 1st 06 05:35 AM


All times are GMT +1. The time now is 12:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"