jinyistudio Well-Known Member Licensed User Longtime User Jun 9, 2016 #1 Hi I have two class as following B4X: dim class1 as jyMbSerial dim class2 as jyMbTcp And i pass them to following function B4X: publice sub Setinterface(intf as object) : end sub SetInterface(class1) Or SetInterface(class2) In SetInterface,How to check intf is jyMbSerial Or jyMbTcp ??
Hi I have two class as following B4X: dim class1 as jyMbSerial dim class2 as jyMbTcp And i pass them to following function B4X: publice sub Setinterface(intf as object) : end sub SetInterface(class1) Or SetInterface(class2) In SetInterface,How to check intf is jyMbSerial Or jyMbTcp ??
Erel B4X founder Staff member Licensed User Longtime User Jun 9, 2016 #2 You can implement SetInterface in each of these classes and then call it with: B4X: CallSub(YourObject, "SetInterface") If you do want to check for the class type then you can use: B4X: If class1 Is jyMbSerial Then Dim m As jyMbSerial = class1 ... Upvote 0
You can implement SetInterface in each of these classes and then call it with: B4X: CallSub(YourObject, "SetInterface") If you do want to check for the class type then you can use: B4X: If class1 Is jyMbSerial Then Dim m As jyMbSerial = class1 ...