Click to See Complete Forum and Search --> : How to declare(Dim) a string array
vasu
January 12th, 2000, 12:34 PM
Hi,
I am new to VB, I do not know how to declare string array.
I tried:
Dim Names As String[]
it giving error.
Can anybody tell me how to declare a string array in VB.
Thanks,
vasu
Leo Koach
January 12th, 2000, 12:47 PM
You can either use
dim string(<the number>) as string
or
dim string() as string
and redim it later
redim string(<the number>) as string
good luck
Leo
vasu
January 12th, 2000, 01:03 PM
Thanks Leo.
But one question:
I declare as Names() As String
But how do I know how many elements are there in the Names array at runtime?
My actual requirement is:
I will have method like GetNames which will take String array as an argument.
This method will be in a DLL.
My client will call this method passing an array.
Now my DLL method should determine(at runtime) how many elements are there and should print out those names.
How can I do this.
Sorry for troubling u.
Thanks,
Vasu
Leo Koach
January 12th, 2000, 01:25 PM
In this case you can guess the largest number that you think user would enter. Since it’s DLL, I assume that “GetString” will accrue while program is running only and after that you can just free the string array and start from the beginning.
Are you going to pass these arrays into a database or a text file later on? You can reset It after “update” or “close” statement..
Leo
Ranjit Goray
January 13th, 2000, 05:23 AM
Dim Names() as String is the syntax
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.