Solved

Class Procedure Question (in an ActiveX EXE)

Posted on 2000-04-10
5
135 Views
Last Modified: 2010-05-02
I have an ActiveX EXE class called clsSimulation which has the basic form:

Public Sub StartSimulation(args ...)

    "Show form code"
    "call dll procedure"

End Sub

Public Sub EndSimulation()

    "Unload form code"

End Sub

My question: why can I only pass one argument to the StartSimulation procedure? Ideally, I would like to pass four arguments as:

x.StartSimulation(arg1,arg2,arg3,arg4)

But VB will not let me ... perhaps their is some basic misunderstanding I have about classes.

Thanks for assistance.
--
Fred Phelan
frederick.phelan@nist.gov
0
Comment
Question by:phalanx777
5 Comments
 

Expert Comment

by:patm_EE
ID: 2701863
I just tested this..

Assuming this:
The Public Sub StartSimulation is a method of your class defined as folows:

Public Sub StartSimulation (str1 as string, str2 as string, str3 as string, str4 as string)

' Do some Stuff

End Sub

You will be REQUIRED to pass 4 arguments...

Maybe I'm missing something...
0
 

Author Comment

by:phalanx777
ID: 2702063
Ok, I did forget to mention that they are not all strings! I am trying to mix a variety of variables in the call to StartSimulation. But it does not really matter, take this specific example:

Public Sub StartSimulation (test_long as Long, test_string as String)

     "code to manipulate test_long and test_string"

End Sub

Then, remember, this is an ActiveX exe. Go to the project you want to us the AXE in ... check it in under references. Then try the code (say in a button callback)

Private Sub Command1_Click()
    Dim test_long As Long
    Dim test_string As String
    test_long = 999
    test_string = "The test string!"
    Set x = New axe.Class1
    x.StartSimulation (test_long,test_string)
End Sub

You will see that the x.StartSimulation is all in red ... indicating an error and the error message is:

Compile error:

Expected: =


Hopefully that clears things up!

Fred

0
 
LVL 14

Expert Comment

by:wsh2
ID: 2703036
This Procedure declaration requires 1 parameter, with the next three being optional. If Nothing is passed via parameters 2,3+4 the Default Value "None" is placed into them. An Example of useage would be:

call StartSimulation ("X",,"Z")

which would give the result..

varArg1 = "X"
varArg2 = "None"
varArg3 = "Z"
varArg4 = "None"

in the subroutine.

------------------------------------
Public Sub StartSimulation _
(Byval varArg1 as Variant, _
Optional Byval varArg2 as Variant = "None", _
Optional Byval varArg3 as Variant = "None", _
Optional Byval varArg3 as Variant = "None")








   
0
 
LVL 3

Accepted Solution

by:
Gordonp earned 50 total points
ID: 2703128
phalanx777>
ITs a simple thing really

replace

x.StartSimulation (test_long,test_string)

with

x.StartSimulation test_long,test_string

placing ( ) round your parameters is only for when you return a value.

for some reason VB lets you away with it if you only have one parameter.

Call x.StartSimulation (test_long,test_string)

also works. But I dont like it. Try it and see.

Hope this helps

Gordon

0
 

Author Comment

by:phalanx777
ID: 2704251
You hit the nail on the head! Problem solved!

Thanks, Fred


0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to skip loop 6 58
Using "ScreenUpdating" 6 66
VBA filters 2 62
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 49
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question