CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 1999
    Location
    Silicon Valley, California
    Posts
    33

    How to declare(Dim) a string array

    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


  2. #2
    Join Date
    Nov 1999
    Location
    US NJ
    Posts
    113

    Re: How to declare(Dim) a string array

    You can either use

    dim string(<the number&gt as string

    or

    dim string() as string

    and redim it later

    redim string(<the number&gt as string

    good luck

    Leo


  3. #3
    Join Date
    Apr 1999
    Location
    Silicon Valley, California
    Posts
    33

    Re: How to declare(Dim) a string array

    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


  4. #4
    Join Date
    Nov 1999
    Location
    US NJ
    Posts
    113

    Re: How to declare(Dim) a string array

    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


  5. #5
    Join Date
    Nov 1999
    Posts
    9

    Re: How to declare(Dim) a string array

    Dim Names() as String is the syntax


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured