borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Next Topic (Milage calculator) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Array Refrencing
Poster Message
mrcoolcurrent
Level: Big Cheese

Registered: 19-01-2007
Posts: 21

icon Array Refrencing

I have an array as below:


       A     B     C     D     E
A     0    10     20   30   40

B    10    0      15   20   30

C    20   15     0     25   30

D    30   20    25    0     40

E    40   30    30    40    0


I also have 2 variables named;

(1) TOO (to indicate Row)
(2) FROM (to indicate collumn)

I want my variable to be the refrence for my array
e.g if TOO= 1
         FROM=2
would return 10 (A,B)

         TOO= 3
         FROM=4
would return 25 (C,D)


         TOO= 3
         FROM=5
would return 30 (C,E)

How can I do this Please

27-12-2007 at 06:17 PM
View Profile Send Email to User Show All Posts | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1158
icon Re: Array Refrencing

Here's a bit of code

Option Explicit
Private numbers(5) As Variant

Private Sub Form_Load()

    numbers(0) = Split("00,10,20,30,40", ",")
    numbers(1) = Split("10,00,15,20,30", ",")
    numbers(2) = Split("20,15,00,25,30", ",")
    numbers(3) = Split("30,20,25,00,40", ",")
    numbers(4) = Split("40,30,30,40,00", ",")

End Sub

Private Sub Command1_Click()

    Dim too As Integer
    Dim from As Integer
    
    too = Val(txtToo.Text) - 1
    from = Val(txtFrom.Text) - 1

    MsgBox numbers(too)(from)

End Sub


Merry Christmas

Steve

27-12-2007 at 10:03 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : Array Refrencing
Next Topic (Milage calculator) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder