|
-
Nov 21st, 2002, 11:58 AM
#1
Thread Starter
New Member
Using CreateObject with CallByName
I'm pretty new to using classes so I would appreciate some help.
I'm using VB6 and I have the following problem:
I need to connect with various instruments via the serial port.
Each instrument has a different set of commands to perform a
number of standard tasks, all instruments are capable of
performing the same standard tasks (methods).
I have created a class for each instrument type: e.g.
clsInstrument1, clsInstrument2 etc..
and each class has the same methods: e.g. CheckCommunications, CloseConnection...
My idea is to have just one select case statement to choose the
instrument class, create an object and then use the same code
for all instrument classes.
This is what I have so far in the calling routine (pseudo-code):
Code:
dim objInstrument as Object
Select Case iInstrumentClass
Case 1
Set objInstrument = CreateObject(clsInstrument1)
Case 2
Set objInstrument = CreateObject(clsInstrument2)
End Select
CallByName objInstrument , CheckCommunications, VbMethod
CallByName objInstrument , CloseConnection, VbMethod
First question: Is there a better way of doing this?
Second question: If this way of doing things is reasonable, do I
have to put the instrument classes into an ActiveX DLL in order
to access them with the CreateObject function?
Many Thanks
-
Nov 22nd, 2002, 02:39 AM
#2
Thread Starter
New Member
[RESOLVED] Using CreateObject with CallByName
I found the answer to this question in the following thread:
http://www.vbforums.com/showthread.p...ss+dynamically
If only I knew the right keywords to search for every time I have a problem!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|