CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2002
    Location
    Foggy California
    Posts
    1,245

    .NET Replacement for VB6's 'Array' keyword?

    In VB6, it was easy to pass a array of a certain type (ok, technically it was a array of variants) into a function as follows:

    Code:
    x = Foo(Array(2,3,5,7)) 'Array of integers
    I know that in VB.NET, I can accomplish the same thing via code like this:

    Code:
    Dim bar(4) as Integer
    
    bar(0) = 2
    bar(1) = 3
    bar(2) = 5
    bar(3) = 7
    
    x = Foo(bar)
    However, this is a lot of extra code to express the same thing. Is there a way in VB.NET to inline the array definition in a single line (similar to what the VB6 code does)?

    Many thanks!

    - Kevin
    Kevin Hall

  2. #2
    Join Date
    Feb 2005
    Location
    Israel
    Posts
    1,475

  3. #3
    Join Date
    Nov 2002
    Location
    Foggy California
    Posts
    1,245

    Re: .NET Replacement for VB6's 'Array' keyword?

    That was easy! Thanks.

    I deal with C++ (ISO, not managed or C++/CLI) 98% of the time and have to dabble with VB.NET every once in a while.

    Thanks again!
    Kevin Hall

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