• Status: Solved
• Priority: Medium
• Security: Public
• Views: 142

Complicated Array Use

Hello,

Hopefully someone here can help me along with this....

I have a multi-dimension array which would look something like this:

B   N27   W38
F   N10   E11
N   S13   W18

etc etc

I now need to do something like the following with it:

For each "row" in the array
Do calculation on the number part of Column 2
IF N assign +ive sign to the answer
IF S assign -ive sign to the answer
Do calculation on the number part of column 3
IF E assign +ive sign to the answer
IF W assign -ive sign to the answer

IF column 1 = B  draw in red
IF column 1 = F  draw in green
IF column 1 = N  draw in blue

NEXT "row"

If anyone can give me some pointers as to how i go about this, that would be great. I've been trying to do this for days :-)

0
codeheaven
• 2
1 Solution

Commented:
' use user defined types.

Option Explicit

Private Type MyType
Field1 as string
Field2 as string
field3 as string
EndType

Private MyData(100) as MyType
Private MyDataCount as long

Private Sub DoCalculations()
Dim i as long

for i = 0 to MyDataCount - 1
IF (Left(MyData(i).Field2, 1) = "N") then
ElseIF (Left(MyData(i).Field2, 1) = "S") then
end if
IF (Left(MyData(i).Field3, 1) = "E") then
ElseIF (Left(MyData(i).Field3, 1) = "W") then
end if

IF (column 1 = B) then drawColour = vbred
IF (column 1 = F) then drawColour = vbgreen
IF (column 1 = N) then drawColour = vbBlue
next i
End Sub

' Good luck!
0

Author Commented:
Thanks supunr!

Just one thing though... how do i populate this user defined type from my array? If the array name is something like strResults()?
0

Commented:
MyDataCount = 10

for i = 0 to MyDataCount-1
MyData(i).Field1 = "B"
MyData(i).Field2 = "N123"
MyData(i).Field3 = "E120"
' etc.
next i
0

Featured Post

• 2
Tackle projects and never again get stuck behind a technical roadblock.