|
-
Feb 12th, 2008, 02:36 AM
#1
Thread Starter
Junior Member
Variable Name to string and determining type of referenced variable
I have two questions that I think are simple, but are tough to search for, so here i am
Firstly, I'd like to get a variable name into a string. Ex:
Dim TestVar as integer = 12 <-- The variable type or value shouldn't matter
Dim TestStr as string
TestStr = "The name is " & name(TestVar)
Therefore the value of TestStr should be "The name is TestVar"
Second, I'd like write a sub with an if statement dependent on the type of variable referred. Ex:
Dim TestVar as double = 1232.5 <-- the value shouldn't matter
Dim TestStr as string
Test(TestVar, TestStr)
Private Sub Test(byRef SubVar, byRef SubStr)
If type(SubVar) = integer then
SubStr = "It's an integer"
ElseIf type(SubVar) = double then
SubStr = "It's a double"
Else
SubStr = "It's something else"
End If
End Sub
Therefore the value of TestStr (or SubStr) should be "It's a double"
Is there a simple way to do these?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|