Simple Introspection Question - Get property Type

I have a class: myClass
It has a field: myField

How do I determine if myClass.myField is an integer or a string (or currency , a folderitem, string() etc) ?

what is myField? TextField, TextArea, Label, Property ?

I think you fill myField with text, so you should know what it is .?

See
https://documentation.xojo.com/index.php/PropertyInfo.PropertyType

Dim d as New Date
Dim myProperties() as Introspection.PropertyInfo = Introspection.GetType(d).GetProperties
For i as Integer=0 to Ubound(myProperties)
  ListBox1.AddRow (myProperties(i).PropertyType.Fullname)
Next
1 Like

Apparently someone felt offended by my above post.
I apologize to all those who feel offended.

Axel, I don’t find your questions offending at all. If a programmer is not able to remember the type of variables and even confuses controls and properties, his code must be extremely strange. Even introspection cannot help, sometimes…

[quote=372267:@Axel Schneider]what is myField? TextField, TextArea, Label, Property ?

I think you fill myField with text, so you should know what it is .?[/quote]

If myField is an auto then it gets set to the type of the first piece of data you give it, so its a valid question when dealing a generic piece of code that can handle a number of types which is why introspection would be needed.

Auto is much less permissive than Variant, though. Yet, Norman use to say Variant is evil.

In a strong typed language such as Xojo, using chameleonesque types should be reserved to very limited use cases.