我想获取一个 VB6 变量的名称作为字符串值,以便在我正在使用的日志记录工具中处理它,如下所示(请检查!!!VariableName!!!)。
有什么办法可以实现这一点吗?我对 VB6 还很陌生,我应该维护和调试现有的旧 VB6 代码。
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
最佳答案
这在 VB6 中是不可能的。您必须传递变量的名称。
AddVariableValue2Log(True, "MyFunction", "MyVariable", MyVariable, Now())
关于string - 获取字符串值形式的 VB6 变量名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11985293/