Android Question Using IS to determine type of object

janderkan

Well-Known Member
Licensed User
Longtime User
I have a List of objects. I can determine if an object is f.ex. Byte or Int.
Can not find out if the object is another List or Array, f.ex. Array of Bytes.
Jan
 

janderkan

Well-Known Member
Licensed User
Longtime User
Found a little error in Gettype(StringArray()).
It returns '[Ljava.lang.String;' the correct should be '[L'
 
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
Here is a routine that can replace GetType and give a more uniform output.


Sub GetType2(Var As Object) As String

Dim Res As String
Dim VarType As String = GetType(Var)

If VarType.StartsWith("[") Then
Dim SecondChar As String = VarType.SubString2(1,2)
Select Case SecondChar.ToUpperCase
Case "B"
Res = "[Byte]"
Case "C"
Res = "[Char]"
Case "S"
Res = "[Short]"
Case "I"
Res = "[Int]"
Case "J"
Res = "[Long]"
Case "F"
Res = "[Float]"
Case "D"
Res = "[Double]"
Case "L"
Res = "[String]"
Case Else
Res = ""
End Select
Else
Select Case VarType.ToUpperCase
Case "JAVA.LANG.BYTE"
Res = "Byte"
Case "JAVA.LANG.CHARACTER"
Res = "Char"
Case "JAVA.LANG.SHORT"
Res = "Short"
Case "JAVA.LANG.INTEGER"
Res = "Int"
Case "JAVA.LANG.LONG"
Res = "Long"
Case "JAVA.LANG.F"
Res = "Float"
Case "JAVA.LANG.DOUBLE"
Res = "Double"
Case "JAVA.LANG.STRING"
Res = "String"
Case Else
Res = ""
End Select
End If

Return Res

End Sub
 
Upvote 0
Top