Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any way to make the data type a memvar?

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
568
US
Colleagues,
Imagine the situation where you don't know the data type of a, say, parameter passed to your Procedure. Then you do something like

Code:
Dim liVarType As Integer = VarType(tArg)

Then you need some local memvar of the same type (say, substring to find, or an index number), or... you've got the idea.
All I could think about was something like this:

Code:
Dim liVarType As Integer = VarType(tArg)

Select Case liVarType
Case VariantType.Char
   Dim lvMyLocalMemvar As Char
Case VariantType.Date
   Dim lvMyLocalMemvar As Date
Case VariantType.Decimal
...
End Select

Is there any way to assign Memvar's data type directly? Something like:

Code:
Dim lvMyLocalMemvar As (VariantType.(VarType(tArg)))

Yes, I understand that VariantType is just a kind of array holding integers as IDs of this or that data type. I'm just trying to convey the idea.

Regards,

Ilya
 
Have a look at method overloading, as that might offer a solution
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top