dustinto

I am trying to figure out the best way to do something:

I have 2 datasets. One dataset is called Grid and the other is Coords.

I want to do a

For Each CurrentRecord As Datarow in Coords

In this For Loop I want to subtract each CurrentRecord Value from each CurrentRecord value in Grids and out put them to an array

So now I should have seperate arrays for each CurrentRecord value.
ie example data/database setup
Coords Table
Record | X1 = 5
Record | X2 = 3
Record | X3 = 5
Record | X4 = 10

Grid Table
Record | A = 1
Record | B = 2
Record | C =3
Record | D = 4

The out put after running the For Loop should be to this effect

Array 1
X1Angel = 5-1 = 4
X1Beer = 5-2 = 3
X1Coffee = 5-3 = 2
X1Drinks = 5-4 = 1

Array 2
X2Angel = 3-1 = 2
X2Beer = 3-2 = 1
X2Coffee = 3-3 = 0
X2Drinks = 3-4 = -1

Array 3
X3Angel = 5-1 = 4
X3Beer = 5-2 = 3
X3Coffee = 5-3 = 2
X3Drinks = 5-4 =1

Array 4
X4Angel = 10-1 = 9
X4Beer = 10-2 = 8
X4Coffee = 10-3 = 7
X4Drinks = 10-4 = 6

Okay now that we have the data in an array I would like to run a IF Then statement (maybe) to find out which number is the lowest in each array

Array 1
X1Drinks = 5-4 = 1

Array 2
X2Drinks = 3-4 = -1

Array 3
X3Drinks = 5-4 =1

Array 4
X4Drinks = 10-4 = 6

In this sample data all the arrays point to Grid D (this is only sample data and will not the the typical outcome).

I want to either create a new array or dumb this into a new database table/xml file that X1 is D, X2 is D, X3 is D, X4 is D.

I'll also do this for Y and Z, but they will be seperate in data.

Anyone willing to help me get started with this

Thanks







Re: Visual Basic Express Edition Need help sorting this out databases, arrays, for loops, etc

ahmedilyas

well basically you got it right, you need to loop through each row from 1 table within the other...if that makes sense.

you need to know however that the current column of data is an integer type otherwise you would get errors.

question is, which column are these values stored in

basically itll be something like this..

for each outerrow in table1

for each innerrow in table2

add to array, outterrow(column) - innerrow(column)

next

next