Solved

Sub problem

Posted on 1998-10-07
9
170 Views
Last Modified: 2010-04-30
I do something in a Sub for a String array
Sub (S() As String)
   S(0)=...
   ...
End Sub
I need to do the very similar thing for an Integer array as well. How can I use the same array with a littel bit changing?
0
Comment
Question by:victorlong
9 Comments
 
LVL 1

Expert Comment

by:blwatkins
ID: 1438633
if you are saying that you are trying to pass two arrays in and out, such as: "Sub (S() as string, I() as integer)", then change the sub to a function instead of a sub..
0
 

Author Comment

by:victorlong
ID: 1438634
No, I want pass only one array each time.
My question realy is how to make the following two Subs into one Sub.
Sub (S() As String)
       S(0)=...
       ...
End Sub
Sub (I() As Integer)
       I(0)=...
       ...
End Sub
 
0
 

Author Comment

by:victorlong
ID: 1438635
To  blwatkins:

Sorry. I found something wrong in my question, I should say
"How to use the same Sub with a littel bit changing to deal with another array with different declearation"?

You are wellcome to re-answer my question, or ask me to explain more clearly.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1438636
Sub( I() as variant )

0
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.

 

Author Comment

by:victorlong
ID: 1438637
To mark2150:

Thank you, I will try. However, do you think variant need much more memory or much slow?
0
 

Author Comment

by:victorlong
ID: 1438638
I have tried

dim I() As Integer, S() As String
Test I()
Test S()
Sub Test( I() as variant )
..
End Sub

and got error!

0
 
LVL 15

Expert Comment

by:Eyal
ID: 1438639
can you send the code you are writen so far?
0
 
LVL 6

Expert Comment

by:andyclap
ID: 1438640
don't forget to declare them byval, so that vb can convert them to variants...

sub Test(byval v() as variant)

Variants are fairly slow compared to ints. We could get into a wonderful discussion on polymorphism here, but I'm about to go home!
0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 40 total points
ID: 1438641
Just declare it like
private Sub MySub(S as variant)

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

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…
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…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

896 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

13 Experts available now in Live!

Get 1:1 Help Now