Solved

Class Procedure Question (in an ActiveX EXE)

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

759 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

23 Experts available now in Live!

Get 1:1 Help Now