J
John Bentley
I have two tasks that I expect will be straight forward to anyone with
reflection skills.
1. To return the the name of an object instance (not type) determined at run
time.
For example, I would like to call a function that takes a basic variable and
writes to the debug window the name of the variable and value.
Dim myNumber As Integer = 12
Dim firstName as String = "Barry"
OutputFieldAndValue(myNumber)
OutputFieldAndValue(firstName)
' Gives something like
myNumber : 14
firstName : Barry
Sub OutputFieldAndValue( _
ByVal field As Object)
Dim pad AS Integer = 10
Dim tabs As String = StrDup(1, Tab)
Dim fieldName As String = "Not yet Implemented"
Dim value As String = field.ToString()
Debug.WriteLine(fieldName.PadRight(pad) & ":" _
& tabs & value.ToString.PadLeft(pad))
End Sub
What could "Not yet Implemented" be replaced with?
2. The name of the current procedure.
Eg
Function FunnyFunction() as Object
Debug.WriteLine( ' some statement that out puts "FunnyFunction" ' )
End Function
reflection skills.
1. To return the the name of an object instance (not type) determined at run
time.
For example, I would like to call a function that takes a basic variable and
writes to the debug window the name of the variable and value.
Dim myNumber As Integer = 12
Dim firstName as String = "Barry"
OutputFieldAndValue(myNumber)
OutputFieldAndValue(firstName)
' Gives something like
myNumber : 14
firstName : Barry
Sub OutputFieldAndValue( _
ByVal field As Object)
Dim pad AS Integer = 10
Dim tabs As String = StrDup(1, Tab)
Dim fieldName As String = "Not yet Implemented"
Dim value As String = field.ToString()
Debug.WriteLine(fieldName.PadRight(pad) & ":" _
& tabs & value.ToString.PadLeft(pad))
End Sub
What could "Not yet Implemented" be replaced with?
2. The name of the current procedure.
Eg
Function FunnyFunction() as Object
Debug.WriteLine( ' some statement that out puts "FunnyFunction" ' )
End Function