I have a method that I want to be able to call and pass in the object type. For example:
myMethod(me)
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?
Class Window1
Inherits Window
// 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
End If
End Sub
// Window1 Control PushButton1:
Sub Action()
passobj(me)
End Sub
End Class
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.
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.