Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Class Procedure Question (in an ActiveX EXE)

Posted on 2000-04-10
5
Medium Priority
?
143 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
Suggested Courses

721 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