Compare numeric values

1. Senior Member
Join Date
Dec 1969
Posts
275

## Compare numeric values

Does anyone know how I would create a function that would take in 3 numeric values and return the largest value of the 3...Thanks

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

## are you serious?

umm, create a var called largest.<BR><BR>convert each to a subtype of double<BR><BR>set the first one to largest<BR>check against 2 and 3, if either is larger, set to largest<BR>......

3. Senior Member
Join Date
Dec 1969
Posts
11,334

## Sounds like school is back in session

with these type of questions.<BR><BR>Ah well... gots to start somewhere.

4. Senior Member
Join Date
Dec 1969
Posts
275

## RE: Sounds like school is back in session

NO need to be smart...while I can do it this way , I was wondering if there was any better way of doing it..but if you don&#039;t know then that is fine...Thanks

5. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## You go girl

i am proud of you<BR><BR><BR><BR>why cant people just answer questions instead of mouthing off<BR><BR><BR>HMPH<BR><BR>

6. Senior Member
Join Date
Dec 1969
Posts
506

## No built in function

like a Max() in VB. You have to write your own.

7. Senior Member
Join Date
Dec 1969
Posts
1,175

## a better way?

what do you mean?<BR><BR>That is extremely simple to do, and fast.

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

## Okay, since you seem serious...

&#060;%<BR>Function Max( ByVal v1, ByVal v2 )<BR> v1 = CDbl(v1)<BR> v2 = CDbl(v2)<BR> If v1 &#062;= v2 Then Max = v1 Else Max = v2<BR>End Function<BR><BR>a = 17.33<BR>b = "77"<BR>c = Year( Now() ) * Rnd<BR>d = Month( Date + 17 )<BR><BR>Response.Write Max( Max( a, b ), Max( c, d ) )<BR>%&#062;<BR><BR>How about that? By writing a 2-element Max, you can get the max of any number of values by stringing together the calls.<BR>

9. Senior Member
Join Date
Dec 1969
Posts
275

## RE: a better way?

Don&#039;t worry..I like to kep the code as cleanas possible and as reusable as possible, instead of passing in a certain number of values, I have created a function that takes in an array of values(so can be used by other pages in my app) and filters thru the array for the largest..thats all..simply trying to write better, more reusable code..Thanks

10. Senior Member
Join Date
Dec 1969
Posts
275

## RE: Okay, since you seem serious...

Thank you!...

#### Posting Permissions

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