Right below is some visual basic proram that i need for our group project. It's supposed to calculate three dimensional spin characteristics of a golf ball fired out of our cannon and upon hitting an angled plate.
When i try and debug the thing in the excel editor it highlights the red bit and says 'invalid outside procedure'.
I don't no much at all about BASIC and am wondering if anyone would be kind enough to explain whats going on, but most importantly get the bad boy working.
Also, does that data stuff need to be at the end, or is that where i need to input my own data ???
cheers

Rem**Y,Z is the principle point
Rem**Y0(1),Z0(1) is the centre of the first image
Rem**Y(1,1),Z(1,1) is the first node of the first image
Rem**Y(2,1),Z(2,1) is the second node of the first image
Rem**The coordinates for the successive images aresimilar but with the second array
Rem**variable as 2,3 and 4.
Rem**Dimension the arrays
Dim Y0(4), Z0(4), Y(2, 4), Z(2, 4)
Rem**Read in the data
For J% = 1 To 4
READ Y0(J%), Z0(J%)
For I% = 1 To 2
READ Y(I%, J%), Z(I%, J%)
Next I%
Next J%
READ Y, Z, F
Rem**Adjsut the data to allow for the relief displacement
For I% = 1 To 2
For J% = 1 To 4
If 4.536901 - (Y(I%, J%) - Y0(J%) ^ 2 - (Z(I%, J%) - Z0(J%)) ^ 2 < 0) Then X(I%, J%) = 0: GoTo 5
X(I%, J%) = Sqr(4.536901 - (Y(I%, J%) - Y0(J%)) ^ 2 - (Z(I%, J%) - Z0(J%)) ^ 2)
5 R(I%, J%) = Sqr((Y(I%, J%) - Y) ^ 2 + (Z(I%, J%) - Z) ^ 2)
D(I%, J%) = X(I%, J%) * R(I%, J%) * 0.0154
YO(J%) = (J%) - Y: Y(I%, J%) = Y(I%, J%) - Y
Z0(J%) = Z0(J%) - Z: Z(I%, J%) = Z(I%, J%) - Z
K(I%, J%) = Y(I%, J%) * K(I%, J%)
Y(I%, J%) = Y(I%, J%) * K(I%, J%)
Z(I%, J%) = Z(I%, J%) * K(I%, J%)
Y(I%, J%) = Y(I%, J%) - Y0(J%): Z(I%, J%) = Z(I%, J%) - Z0(J%)
If 4.536901 - Y(I%, J%) ^ 2 - Z(I%, J%) ^ 2 Then X(I%, J%) = 0: GoTo 6
X(I%, J%) = Sqr(4.536901 - Y(I%, J%) ^ 2 - Z(I%, J%) ^ 2)
6 Next I%
Next J%
Rem**Modify cartesian coordinates to direct cosines
For J% = 1 To 4
For I% = 1 To 2
X(I%, J%) = X(I%, J%) / 2.13
Y(I%, J%) = Y(I%, J%) / 2.13
Z(I%, J%) = Z(I%, J%) / 2.13
Next I%
Next J%
Rem**Calculate spin vector before impact
If Z(2, 1) - Z(2, 2) = 0 Then A = 1E+20: GoTo 10
A = (Z(1, 1) - Z(1, 2)) / (Z(2, 1) - Z(2, 2))
10 If A * (Y(2, 1) - Y(2, 2)) - Y(1, 1) + Y(1, 2) = 0 Then GoTo 20
B = (X(1, 1) - X(1, 2) - A * (X(2, 1) - X(2, 2))) / (A * (Y(2, 1) - Y(2, 2)) - Y(1, 1) + Y(1, 2))
C = 1 + B * B + ((X(1, 1) - X(1, 2) + B * (Y(1, 1) - Y(1, 2))) / (Z(1, 2) - Z(1, 1))) ^ 2: GoTo 30
20 B = 1E+20: C = 1E+20
30 Xb = Sqr(1 / C)
Yb = B * Xb
Zb = Sqr(1 - (1 + B * B) * Xb * Xb)
Rem**Calculate rotation before impact
ANGb = Xb * X(1, 1) + Yb * Y(1, 1) + Zb * Z(1, 1)
ANGb = -Atn(ANGb / Sqr(-ANGb * ANGb + 1)) + 1.570796
R = 4.26 * Sin(ANGb)
D = Sqr((X(1, 1) - X(1, 2)) ^ 2 + (Y(1, 1) - Y(1, 2)) ^ 2 + (Z(1, 1) - Z(1, 2)) ^ 2)
ROTb = D / R
ROTb = 2 * Atn(ROTb / Sqr(-ROTb * ROTb + 1))
Rem**Calculate spin vector after impact
If Z(2, 3) - Z(2, 4) = 0 Then A = 1E+20: GoTo 10
A = (Z(1, 3) - Z(1, 4)) / (Z(2, 3) - Z(2, 4))
10 If A * (Y(2, 3) - Y(2, 4)) - Y(1, 3) + Y(1, 4) = 0 Then GoTo 20
B = (X(1, 3) - X(1, 4) - A * (X(2, 3) - X(2, 4))) / (A * (Y(2, 3) - Y(2, 4)) - Y(1, 3) + Y(1, 4))
C = 1 + B * B + ((X(1, 3) - X(1, 4) + B * (Y(1, 3) - Y(1, 4))) / (Z(1, 4) - Z(1, 3))) ^ 2: GoTo 30
20 B = 1E+20: C = 1E+20
30 Xa = Sqr(1 / C)
Ya = B * Xa
Za = Sqr(1 - (1 + B * B) * Xa * Xa)
Rem**Calculate rotation after impact
ANGa = Xa * X(1, 3) + Ya * Y(1, 3) + Za * Z(1, 3)
ANGa = -Atn(ANGa / Sqr(-ANGa * ANGa + 1)) + 1.570796
R = 4.26 * Sin(ANGa)
D = Sqr((X(1, 3) - X(1, 4)) ^ 2 + (Y(1, 3) - Y(1, 4)) ^ 2 + (Z(1, 3) - Z(1, 4)) ^ 2)
ROTb = D / R
ROTb = 2 * Atn(ROTb / Sqr(-ROTb * ROTb + 1))
Rem**Output data
Print "*****Before Impact*****"
Print "Spin Vector is ";: Print USING; "+#.##,"; Xb; Yb; Zb
Print "ROTx = ";: Print USING; "+###.##"; ROTb * Xb * F;: Print " rad/s ROTy = ";: Print USING; "+###.##"; ROTb * Yb * F;: Print " rad/s ROTz = ";: Print USING; "+###.##"; ROTb * Zb * F;: Print " rad/s."
Print "Total rotation is ";: Print USING; "+###.##"; ROTb * F;: Print " rad/s"
Print "*****After impact*****"
Print "Spin Vector is ";: Print USING; "+#/##,"; Xa; Ya; Za
Print "ROTx = ";: Print USING; "+###.##"; ROTa * Xa * F;: Print " rad/s, ROTz = ";: Print USING; "+###.##"; ROTa * Za * F;: Print " rad/s."
Print "Total rotation is ";: Print USING; "+###.##"; ROTa * F;: Print " rad/s"
End
DATA 41.4, 18.1
DATA 41.5, 19#
DATA 42.2, 17.9
DATA 33.7, 9.1
DATA 34.4, 9.9
DATA 34.2, 8.6
DATA 41.3, 18#
DATA 41.5, 19.2
DATA 42.2, 17.9
DATA 33.8, 9.2
DATA 34.4, 9.9
DATA 34.2, 8.6
DATA 31#, 14.5, 250
When i try and debug the thing in the excel editor it highlights the red bit and says 'invalid outside procedure'.
I don't no much at all about BASIC and am wondering if anyone would be kind enough to explain whats going on, but most importantly get the bad boy working.
Also, does that data stuff need to be at the end, or is that where i need to input my own data ???
cheers



Rem**Y,Z is the principle point
Rem**Y0(1),Z0(1) is the centre of the first image
Rem**Y(1,1),Z(1,1) is the first node of the first image
Rem**Y(2,1),Z(2,1) is the second node of the first image
Rem**The coordinates for the successive images aresimilar but with the second array
Rem**variable as 2,3 and 4.
Rem**Dimension the arrays
Dim Y0(4), Z0(4), Y(2, 4), Z(2, 4)
Rem**Read in the data
For J% = 1 To 4
READ Y0(J%), Z0(J%)
For I% = 1 To 2
READ Y(I%, J%), Z(I%, J%)
Next I%
Next J%
READ Y, Z, F
Rem**Adjsut the data to allow for the relief displacement
For I% = 1 To 2
For J% = 1 To 4
If 4.536901 - (Y(I%, J%) - Y0(J%) ^ 2 - (Z(I%, J%) - Z0(J%)) ^ 2 < 0) Then X(I%, J%) = 0: GoTo 5
X(I%, J%) = Sqr(4.536901 - (Y(I%, J%) - Y0(J%)) ^ 2 - (Z(I%, J%) - Z0(J%)) ^ 2)
5 R(I%, J%) = Sqr((Y(I%, J%) - Y) ^ 2 + (Z(I%, J%) - Z) ^ 2)
D(I%, J%) = X(I%, J%) * R(I%, J%) * 0.0154
YO(J%) = (J%) - Y: Y(I%, J%) = Y(I%, J%) - Y
Z0(J%) = Z0(J%) - Z: Z(I%, J%) = Z(I%, J%) - Z
K(I%, J%) = Y(I%, J%) * K(I%, J%)
Y(I%, J%) = Y(I%, J%) * K(I%, J%)
Z(I%, J%) = Z(I%, J%) * K(I%, J%)
Y(I%, J%) = Y(I%, J%) - Y0(J%): Z(I%, J%) = Z(I%, J%) - Z0(J%)
If 4.536901 - Y(I%, J%) ^ 2 - Z(I%, J%) ^ 2 Then X(I%, J%) = 0: GoTo 6
X(I%, J%) = Sqr(4.536901 - Y(I%, J%) ^ 2 - Z(I%, J%) ^ 2)
6 Next I%
Next J%
Rem**Modify cartesian coordinates to direct cosines
For J% = 1 To 4
For I% = 1 To 2
X(I%, J%) = X(I%, J%) / 2.13
Y(I%, J%) = Y(I%, J%) / 2.13
Z(I%, J%) = Z(I%, J%) / 2.13
Next I%
Next J%
Rem**Calculate spin vector before impact
If Z(2, 1) - Z(2, 2) = 0 Then A = 1E+20: GoTo 10
A = (Z(1, 1) - Z(1, 2)) / (Z(2, 1) - Z(2, 2))
10 If A * (Y(2, 1) - Y(2, 2)) - Y(1, 1) + Y(1, 2) = 0 Then GoTo 20
B = (X(1, 1) - X(1, 2) - A * (X(2, 1) - X(2, 2))) / (A * (Y(2, 1) - Y(2, 2)) - Y(1, 1) + Y(1, 2))
C = 1 + B * B + ((X(1, 1) - X(1, 2) + B * (Y(1, 1) - Y(1, 2))) / (Z(1, 2) - Z(1, 1))) ^ 2: GoTo 30
20 B = 1E+20: C = 1E+20
30 Xb = Sqr(1 / C)
Yb = B * Xb
Zb = Sqr(1 - (1 + B * B) * Xb * Xb)
Rem**Calculate rotation before impact
ANGb = Xb * X(1, 1) + Yb * Y(1, 1) + Zb * Z(1, 1)
ANGb = -Atn(ANGb / Sqr(-ANGb * ANGb + 1)) + 1.570796
R = 4.26 * Sin(ANGb)
D = Sqr((X(1, 1) - X(1, 2)) ^ 2 + (Y(1, 1) - Y(1, 2)) ^ 2 + (Z(1, 1) - Z(1, 2)) ^ 2)
ROTb = D / R
ROTb = 2 * Atn(ROTb / Sqr(-ROTb * ROTb + 1))
Rem**Calculate spin vector after impact
If Z(2, 3) - Z(2, 4) = 0 Then A = 1E+20: GoTo 10
A = (Z(1, 3) - Z(1, 4)) / (Z(2, 3) - Z(2, 4))
10 If A * (Y(2, 3) - Y(2, 4)) - Y(1, 3) + Y(1, 4) = 0 Then GoTo 20
B = (X(1, 3) - X(1, 4) - A * (X(2, 3) - X(2, 4))) / (A * (Y(2, 3) - Y(2, 4)) - Y(1, 3) + Y(1, 4))
C = 1 + B * B + ((X(1, 3) - X(1, 4) + B * (Y(1, 3) - Y(1, 4))) / (Z(1, 4) - Z(1, 3))) ^ 2: GoTo 30
20 B = 1E+20: C = 1E+20
30 Xa = Sqr(1 / C)
Ya = B * Xa
Za = Sqr(1 - (1 + B * B) * Xa * Xa)
Rem**Calculate rotation after impact
ANGa = Xa * X(1, 3) + Ya * Y(1, 3) + Za * Z(1, 3)
ANGa = -Atn(ANGa / Sqr(-ANGa * ANGa + 1)) + 1.570796
R = 4.26 * Sin(ANGa)
D = Sqr((X(1, 3) - X(1, 4)) ^ 2 + (Y(1, 3) - Y(1, 4)) ^ 2 + (Z(1, 3) - Z(1, 4)) ^ 2)
ROTb = D / R
ROTb = 2 * Atn(ROTb / Sqr(-ROTb * ROTb + 1))
Rem**Output data
Print "*****Before Impact*****"
Print "Spin Vector is ";: Print USING; "+#.##,"; Xb; Yb; Zb
Print "ROTx = ";: Print USING; "+###.##"; ROTb * Xb * F;: Print " rad/s ROTy = ";: Print USING; "+###.##"; ROTb * Yb * F;: Print " rad/s ROTz = ";: Print USING; "+###.##"; ROTb * Zb * F;: Print " rad/s."
Print "Total rotation is ";: Print USING; "+###.##"; ROTb * F;: Print " rad/s"
Print "*****After impact*****"
Print "Spin Vector is ";: Print USING; "+#/##,"; Xa; Ya; Za
Print "ROTx = ";: Print USING; "+###.##"; ROTa * Xa * F;: Print " rad/s, ROTz = ";: Print USING; "+###.##"; ROTa * Za * F;: Print " rad/s."
Print "Total rotation is ";: Print USING; "+###.##"; ROTa * F;: Print " rad/s"
End
DATA 41.4, 18.1
DATA 41.5, 19#
DATA 42.2, 17.9
DATA 33.7, 9.1
DATA 34.4, 9.9
DATA 34.2, 8.6
DATA 41.3, 18#
DATA 41.5, 19.2
DATA 42.2, 17.9
DATA 33.8, 9.2
DATA 34.4, 9.9
DATA 34.2, 8.6
DATA 31#, 14.5, 250