Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error message - state all strings


Hi i'm trying to improve an error handler that i'm putting together. I
have a case statement based on an error number. If the error is due to
a string value being null i would like to list all strings in a message
box or something and show all the values?

My question is whether there is a function that will state all strings
being used at that time and their particular value? My code is
relativly long and this would help with debugging Thanks


--
cereldine
------------------------------------------------------------------------
cereldine's Profile: http://www.excelforum.com/member.php...o&userid=32069
View this thread: http://www.excelforum.com/showthread...hreadid=554916

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Error message - state all strings

I'm not sure what you mean by "a string value being null". A variable
declared As String can be empty (unassigned), a vbNullString, or empty
string "", technically not quite the same but for most practical purposes
can be regarded as such and confirmed with -

Len(myString) = 0

A String cannot contain a Null value which can only be assigned to a
Variant. However trying to assign Null to a string would indeed raise an
error (94 probably) but would not change any existing string value.

You would need to roll your own function to return values of your strings.

Regards,
Peter T


"cereldine" wrote in
message ...

Hi i'm trying to improve an error handler that i'm putting together. I
have a case statement based on an error number. If the error is due to
a string value being null i would like to list all strings in a message
box or something and show all the values?

My question is whether there is a function that will state all strings
being used at that time and their particular value? My code is
relativly long and this would help with debugging Thanks


--
cereldine
------------------------------------------------------------------------
cereldine's Profile:

http://www.excelforum.com/member.php...o&userid=32069
View this thread: http://www.excelforum.com/showthread...hreadid=554916



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error message - state all strings


Sorry should have explained myself better, i have a lot of worksheets
that open depending on a string value, there have been occassions when
i have been debugging when these strings or search values have been
blank, i thought that if i could output all the current strings with
the value they hold at the time of error then i could narrow down
problem.

Perhaps a better way of putting it would be how do i return the values
for all variables in my procedure at the time when code breaks?


--
cereldine
------------------------------------------------------------------------
cereldine's Profile: http://www.excelforum.com/member.php...o&userid=32069
View this thread: http://www.excelforum.com/showthread...hreadid=554916

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Error message - state all strings

Better ways but to quickly find out what's going wrong something like this -

Public gbDebug As Boolean

Sub Test()
Dim bOK As Boolean
Dim s1$, s2$, s3
Dim n As Long

gbDebug = True ' normally set in some other proc
On Error GoTo errH:
s1 = "aaa"
s2 = "bbb"
n = 1 / 0
s2 = "ccc"
bOK = True
done:

MsgBox "All OK: " & bOK

Exit Sub
errH:
If gbDebug Then
Debug.Print "Err: " & Err.Number, Err.Description
Debug.Print "s1: "; s1
Debug.Print "s2: "; s2
Debug.Print "s3: "; s3
Stop
'ctrl-g to view Immediate window
' F8 to step to line that triggered error
' or drag yellow cursor down to skip
Resume
End If
Resume done
End Sub

Regards,
Peter T

"cereldine" wrote
in message ...

Sorry should have explained myself better, i have a lot of worksheets
that open depending on a string value, there have been occassions when
i have been debugging when these strings or search values have been
blank, i thought that if i could output all the current strings with
the value they hold at the time of error then i could narrow down
problem.

Perhaps a better way of putting it would be how do i return the values
for all variables in my procedure at the time when code breaks?


--
cereldine
------------------------------------------------------------------------
cereldine's Profile:

http://www.excelforum.com/member.php...o&userid=32069
View this thread: http://www.excelforum.com/showthread...hreadid=554916



Reply
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
replace state names with state code abbreviations se7098 Excel Worksheet Functions 3 July 25th 09 06:41 PM
How can I show state-by-state data (as silos) on a map of NA Rob Charts and Charting in Excel 0 November 5th 07 03:41 PM
Converting State Names to State Abbreviations aznate Excel Discussion (Misc queries) 1 October 20th 06 06:52 AM
Type mismatch error problem when dealing with Strings David Goodall[_2_] Excel Programming 4 June 30th 05 01:40 PM
changing the message in an error message The Villages DA Excel Worksheet Functions 2 February 18th 05 05:30 PM


All times are GMT +1. The time now is 01:07 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"