Android Question Testing the type of a variable


Well-Known Member
Licensed User
Once again, I'm pondering my settings framework. I still don't like to have:

* SettingStr(Key as string, Value as string, Write as bool) as string
* SettingInt(Key as string, Value as int, Write as bool) as int
* SettingLong(Key as string, Value as long, Write as bool) as long
* SettingBool(Key as string, Value as bool, Write as bool) as bool
* SettingFloat(Key as string, Value as float, Write as bool) as float
* SettingDouble(Key as string, Value as double, Write as bool) as double
* SettingDate(Key as string, Value as long, Write as bool) as long
Yet, I do want to do some special stuff on some types, to maintain human readability. This mainly applies to bools (save as Yes/No) and dates (save in ISO format).

As overloading is not likely to happen soon, I started thinking about doing this:

* Setting(Key as string, Value as object, Write as bool) as object
Then I'd test the type of the Value argument and do whatever formatting needed. Possible?


Well-Known Member
Licensed User
did you try:
    Dim o As Object
    o = Setting("abc","abc",True)
    Dim VarType As String = GetType(o)
and then parse the return string like:
  • java.lang.String
  • java.lang.Double
....and so on