Solved

Class Procedure Question (in an ActiveX EXE)

Posted on 2000-04-10
5
134 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now