Comparing Values...Hey Bill Sorry for the last..

# Thread: Comparing Values...Hey Bill Sorry for the last..

1. Senior Member
Join Date
Dec 1969
Posts
2,880

## Comparing Values...Hey Bill Sorry for the last..

post. I couldn&#039;t answer back since I was away since but it did help after a few changes. Thanks.<BR><BR>I have a table with 5 columns with 5 different numerical values. How do I compare between each of them for a specific ID which has the lowest value?<BR><BR>Thanks!

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## With only 5, I'd just use brute force

Dim values(4)<BR>values(0) = RS("whatever")<BR>values(1) = RS("something")<BR>values(2) = RS("yep")<BR>values(3) = RS("works")<BR>values(4) = RS("okay")<BR><BR>and then sort the values array.<BR><BR>If it&#039;s important that you also know the name of the field that had/has the biggest value then it&#039;s more complex.<BR><BR>

3. Senior Member
Join Date
Dec 1969
Posts
2,880

## Any other way apart from that...

Thanks!

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## What's wrong with that???

Esp. since you are working in VB, that should be easy enough. Doesn&#039;t VB have a built-in array sort routine? (Or is that VB.NET only?)<BR><BR>

5. Senior Member
Join Date
Dec 1969
Posts
2,880

## Just looking at various method..

Yeah I&#039;m working in VB.

6. Senior Member
Join Date
Dec 1969
Posts
2,880

## What do you mean...

Sort the values arrays?

7. Senior Member
Join Date
Dec 1969
Posts
96,118

## RE: What do you mean...

Dim [hl="yellow"]values[/hl](4) <BR>[hl="yellow"]values[/hl](0) = RS("whatever") <BR>[hl="yellow"]values[/hl](1) = RS("something") <BR>[hl="yellow"]values[/hl](2) = RS("yep") <BR>[hl="yellow"]values[/hl](3) = RS("works") <BR>[hl="yellow"]values[/hl](4) = RS("okay") <BR><BR>[hl="yellow"]values[/hl] is the NAME of an array that I dimensioned using the DIM statement. Which I then put 5 values into using the next 5 statements above.<BR><BR>So when I wrote "sort the [hl="yellow"]values[/hl] array" I meant sort the array named [hl="yellow"]values[/hl] in the code that I showed you.<BR><BR>What POSSIBLE [hl="yellow"]other[/hl] meaning could you attach to that statement? I am truly mystified.<BR><BR>

8. Senior Member
Join Date
Dec 1969
Posts
2,880

## Do I then...

What should I dim values as within VB?

9. Senior Member
Join Date
Dec 1969
Posts
96,118

## Whatever matches...

...the types in the DB. How can *I* know the answer????<BR><BR>If they are all integers, then DIM the array as an array of integers. If they are alls VARCHAR, then DIM it as an array of strings.<BR><BR>Or dim it as an array of VARIANT, though then the idea of sorting mixed strings and numbers and whatnot seems really strange.<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•