arrays in vb.net !

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
 
A

Armin Zingler

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?
 
J

J P Deka

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"
 
A

Armin Zingler

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top