Reputation: 4901
I would like to get a VB6 variable's name as a string value in order to handle it in a logging facility I am using like the following one (please check !!!VariableName!!!).
Is there any way to achieve this? I am pretty new to VB6 and I am supposed to maintain and debug existing old VB6 code.
Public Sub AddVariableValue2Log(ByVal checkDebug, _
ByVal sFunctionName As String, _
ByVal sVariableValue As String, _
ByVal sTimeStamp As String)
If checkDebug Then
Dim sLogPath As String
sLogPath = "C:\Temp\Log_" & sTimeStamp & ".txt"
Dim fn As Integer
fn = FreeFile
Open sLogPath For Append As #fn
Write #fn, Now & "|" & sFunctionName & "|>>>!!!VariableName!!! value: [" & sVariableValue & "]"
Close #fn
End If
End Sub
Upvotes: 4
Views: 1851
Reputation: 3685
It is not possible in VB6. You have to pass name of the variable.
AddVariableValue2Log(True, "MyFunction", "MyVariable", MyVariable, Now())
Upvotes: 6