I have a method that I want to be able to call and pass in the object type. For example:
In the method itself I then want to be able to do if statements and do things if the object is of different types e.g. label, text field, listbox etc.
I am guessing that I use “isA” in the if statement but I dont not what to put in the parameter for the method to store the type into? Should I use variant or something else?
How about “RectControl”? No variants please - these show your VB background
Brilliant, just looked that up in the docs and it looks like what I need, yes I am showing my VB age!!! Thanks for the quick response.
// Window1.passobj Method:
Protected Sub passobj(obj As Object) // <-- Example method receiving any kind of objects
if obj isa PushButton then
msgbox "Received a Push Button: "+PushButton(obj).Name
// Window1 Control PushButton1:
Thanks Rick that is exactly what I was after.
The other option is to create an interface, and then make subclasses of the controls and have them implement the interface
Now you have just totally blown my head!!! I have just got my head around classes and oops and when I started to read about interfaces and how you can make things have multiple faces with the same thing I decided I would leave that part of the book until a later stage By the way, great book called Demystifying OOPs explains the whole OOPs thing in a very simple way and the book is non language specific and a really easy read for anyone new to OOPs.
I case anyone is interested: Amazon
Thanks for that second post, giving the Amazon location. I Googled the Demystifying OOPs, and much to my surprise the book didn’t appear, at least not on the first page of hits.
Yup, ordered the book and now have it in my possession. I’ve been programming for over close to 50 years and never with an OOPs language until going to RB back at version 1.1. I can achieve the things that I set out to do; but, it would be nice to more fully understand what some of you folks keep tossing out there in your replies.
What I toss out in my replies is total gibberish but everyone else seems to understand OOPs and talks so highly about it I thought I should try and get to grips with it. This book is really easy to grasp how and why it should be used and is written in chunks that make it easy to read a bit and then go an try it in Xojo, then go back and read a bit more. You feel like you are getting somewhere. Gook luck with the book, I hope you find it as useful as I do.