Archived

This topic is now archived and is closed to further replies.

Guess can't do this in Visual Basic

This topic is 6354 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all. Instead of doing a huge if "if object1 is object2" etc, do (this or something to this effect): select object1 case is object2 etc... Please, correct me if wrong, thank you. Topgoro

Share this post


Link to post
Share on other sites
quote:
Original post by Topgoro

Hi all.

Instead of doing a huge if "if object1 is object2" etc,

do (this or something to this effect):

select object1
case is object2
etc...

Please, correct me if wrong, thank you.

Topgoro



There shouldn''t be any problems. I''ve done Select Case lots of times. Mainly for grouped radio buttons. Look in the VB Help files under "Select" keyword.


B e S
It's Da BOMB Baby!!!

Share this post


Link to post
Share on other sites
I use VB5 and it''s probably not a good idea to do:

Select Case Object1
Case Object2: ...
Case Object3: ...
End Select

for the reason that I don''t believe it is comparing objects, but the default property (if you have set one).

Rather, you can do something like:

Select Case ObjPtr(Object1)
Case ObjPtr(Object2): ...
Case ObjPtr(Object3): ...
End Select

Where ObjPtr is a hidden function in VB. There is also StrPtr and VarPtr. Open the Object Browser, right click for the popup menu and select "Show Hidden Members". Sadly there''s nothing else of much interest that''s hidden...

I suspect if the Select works for VB6 then it is comparing the object, not the class of object.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by TPH

I use VB5 and it''s probably not a good idea to do:

Select Case Object1
Case Object2: ...
Case Object3: ...
End Select

for the reason that I don''t believe it is comparing objects, but the default property (if you have set one).

Rather, you can do something like:

Select Case ObjPtr(Object1)
Case ObjPtr(Object2): ...
Case ObjPtr(Object3): ...
End Select

Where ObjPtr is a hidden function in VB. There is also StrPtr and VarPtr. Open the Object Browser, right click for the popup menu and select "Show Hidden Members". Sadly there''s nothing else of much interest that''s hidden...

I suspect if the Select works for VB6 then it is comparing the object, not the class of object.



Hi all.

Thank you very much for your response

I tried the first case in VB 6 SP3 and it did not work. How ever, I tried using the ObjPtr function and it worked as expected. Too bad I still can''t use it in Sax BASIC.

Topgoro

Share this post


Link to post
Share on other sites