Sub problem

Posted on 1998-10-07
Last Modified: 2010-04-30
I do something in a Sub for a String array
Sub (S() As String)
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?
Question by:victorlong
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

Expert Comment

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

Author Comment

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)
End Sub
Sub (I() As Integer)
End Sub

Author Comment

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.
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

LVL 12

Expert Comment

ID: 1438636
Sub( I() as variant )


Author Comment

ID: 1438637
To mark2150:

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

Author Comment

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!

LVL 15

Expert Comment

ID: 1438639
can you send the code you are writen so far?

Expert Comment

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!
LVL 13

Accepted Solution

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


Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

690 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