arrays in vb.net !

  • Thread starter Thread starter Tim Eaden
  • Start date Start date
T

Tim Eaden

I use for next loops to write data to an array in vb6

dim j as int
dim data(10) as string

for j = 1 to 10

data(j)= function.whatever(j)

next

I cant get this to work with vb.net
How do I create and address elements in an array like
above
Any help much appreciated
TIM
 
Tim Eaden said:
I use for next loops to write data to an array in vb6

dim j as int
dim data(10) as string

for j = 1 to 10

data(j)= function.whatever(j)

next

I cant get this to work with vb.net
How do I create and address elements in an array like
above

The same way. Where's the problem? Do you get a build or a run time error?
 
Use in this way

Dim arr(10) As String

Dim i As Integer = 0

For i = 0 To arr.Length - 1

' do your job

Next

because array indexing starts from "Zero"
 
J P Deka said:
Use in this way

Dim arr(10) As String

Dim i As Integer = 0

For i = 0 To arr.Length - 1

' do your job

Next

because array indexing starts from "Zero"

It also started from zero in VB6, if Option Base was not used.
 
Back
Top