Creating Array of Point

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I create an array of points using a loop? I wrote the following code that doesn't seem to be working

Dim allPoints() As Poin
Dim i As Intege
For i = 0 To 100
Dim myPoint As New Point(i , i*2
allPoints(i) = myPoint 'this line causes the problem
Next
 
Amjad said:
How do I create an array of points using a loop? I wrote the
following code that doesn't seem to be working:

Dim allPoints() As Point
Dim i As Integer
For i = 0 To 1000
Dim myPoint As New Point(i , i*2)
allPoints(i) = myPoint 'this line causes the problem!
Next

In what way is it not working? Please give a short and complete program
which demonstrates the problem, rather than just a snippet.
 
Please post VB.NET questions to microsoft.public.dotnet.languages.vb.

How do I create an array of points using a loop? I wrote the following code that doesn't seem to be working:

Dim allPoints() As Point

This just declares an uninitialized array (it's Nothing by default),
you have to initialize before use.

Dim allPoints(1000) As Point



Mattias
 
Your array doesnt seem to be initialized. (have a dimension on it) So
you're probably getting an index out of range
 

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

Back
Top