?
Solved

Complicated Array Use

Posted on 2003-03-30
3
Medium Priority
?
141 Views
Last Modified: 2010-05-01
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

   Draw Point (Answer2, Answer1)
    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
Comment
Question by:codeheaven
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
supunr earned 300 total points
ID: 8235555
' 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
   Dim Answer1 as long
   Dim Answer2 as long


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

       DrawPoint Answer2, Answer1

       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 Comment

by:codeheaven
ID: 8237467
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
 
LVL 11

Expert Comment

by:supunr
ID: 8238192
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question