Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Debug.Print "Test " vbCodeLineNumber & ": " & varName


Is there a way to get debug.print to print the current line number o
the code? (similar to Debug.Print "Test " vbCodeLineNumber & ": "
varName)

thank

--
TommySzalapsk
-----------------------------------------------------------------------
TommySzalapski's Profile: http://www.excelforum.com/member.php...fo&userid=2556
View this thread: http://www.excelforum.com/showthread.php?threadid=39216

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Debug.Print "Test " vbCodeLineNumber & ": " & varName

TommySzalapski wrote:
Is there a way to get debug.print to print the current line number of
the code? (similar to Debug.Print "Test " vbCodeLineNumber & ": " &
varName)

thanks


I you enable line numbers in a function and then raise an error from
that function, you can get the line number, so:

Option Explicit
Private Const LOG_VARIABLE As Long = vbObjectError + 1

Sub LogVariable(varName As String, varValue As String)
Dim vval
vval = Split(varName, "::")
Debug.Print vval(0) & "(" & vval(2) & ") " & vval(1) & " = " & varValue
End Sub

Sub Test()
10 On Error GoTo Failed
15 Dim MyVar As String
20 MyVar = "Variable has been set"
30 Err.Raise LOG_VARIABLE, "Test::MyVar", MyVar
40 Exit Sub
45 Failed:
50 If Err.Number = LOG_VARIABLE Then
60 LogVariable Err.Source & "::" & Erl, Err.Description
70 Resume Next
80 End If
90 Err.Raise Err.Number, Err.Source, Err.Description
End Sub
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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
Complex if test program possible? If "value" "value", paste "value" in another cell? jseabold Excel Discussion (Misc queries) 1 January 30th 06 10:01 PM
Looking for VB code to test for "RING" , "BUSY" disconnects or other signals BruceJ[_2_] Excel Programming 3 November 20th 03 01:55 AM


All times are GMT +1. The time now is 05:11 AM.

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

About Us

"It's about Microsoft Excel"