Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel | |||
Complex if test program possible? If "value" "value", paste "value" in another cell? | Excel Discussion (Misc queries) | |||
Looking for VB code to test for "RING" , "BUSY" disconnects or other signals | Excel Programming |