passing of array of objects

12 views
Skip to first unread message

lchen...@gmail.com

unread,
Jul 26, 2020, 11:13:57 AM7/26/20
to
Hi, Experts,

I have difficulty compiling the following code, Please help !

All I do is to declare a group of point (of type "Vector", defined in a class) in the main module.
Then I set the value of each point in a subroutine.

The compiler responded "object not initialized". How should I fix it ?

Any response is appriciated.

Larry

-----------------------------------------------------------------------------------------------------


Sub Main()

Dim BallA(36,18) As Vector

Dim C As New Vector, R As Single

CreateBall(C, R, BallA)

......

END Sub
'**********************************************************
'**********************************************************
Sub CreateBall(Center As Vector, R As Single, Ball(,) As Vector)

Dim pi As Single
pi = 3.141592654

Dim Nph As Integer, Nth As Integer
Nph = 36
Nth = 18

Dim ph As Single, th As Single, ph1 As Single, th1 As Single

Dim p1 As New Vector, p2 As New Vector, p3 As New Vector, p4 As New Vector

For i = 1 To Nph
For j = 1 To Nth

ph = (i - 1) / Nph * 2 * pi
th = (j - 1) / Nth * pi
ph1 = i / Nph * 2 * pi
th1 = j / Nth * pi

Ball(i, j).X = Center.X + R * Math.Sin(th) * Math.Cos(ph)
Ball(i, j).Y = Center.Y + R * Math.Sin(th) * Math.Sin(ph)
Ball(i, j).Z = Center.Z + R * Math.Cos(th)

Ball(i + 1, j).X = Center.X + R * Math.Sin(th1) * Math.Cos(ph)
Ball(i + 1, j).Y = Center.Y + R * Math.Sin(th1) * Math.Sin(ph)
Ball(i + 1, j).Z = Center.Z + R * Math.Cos(th1)

Ball(i + 1, j + 1).X = Center.X + R * Math.Sin(th1) * Math.Cos(ph1)
Ball(i + 1, j + 1).Y = Center.Y + R * Math.Sin(th1) * Math.Sin(ph1)
Ball(i + 1, j + 1).Z = Center.Z + R * Math.Cos(th1)

Ball(i, j + 1).X = Center.X + R * Math.Sin(th) * Math.Cos(ph1)
Ball(i, j + 1).Y = Center.Y + R * Math.Sin(th) * Math.Sin(ph1)
Ball(i, j + 1).Z = Center.Z + R * Math.Cos(th)

Next j
Next i

End Sub
Reply all
Reply to author
Forward
0 new messages