• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

Sub problem

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
victorlong
Asked:
victorlong
1 Solution
 
blwatkinsCommented:
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
 
victorlongAuthor Commented:
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
 
victorlongAuthor Commented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mark2150Commented:
Sub( I() as variant )

0
 
victorlongAuthor Commented:
To mark2150:

Thank you, I will try. However, do you think variant need much more memory or much slow?
0
 
victorlongAuthor Commented:
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
 
EyalCommented:
can you send the code you are writen so far?
0
 
andyclapCommented:
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
 
MirkwoodCommented:
Just declare it like
private Sub MySub(S as variant)

0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now