473,390 Members | 1,303 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

Max() function

does .NET have a Max() function ?

something like

MyMaxValue = Max(Value1,Value2,Value3,Value4)
Nov 20 '05 #1
3 29009
"John A Grandy" <johnagrandy-at-yahoo.com> schrieb
does .NET have a Max() function ?

something like

MyMaxValue = Max(Value1,Value2,Value3,Value4)

You can have the IDE search for you. Press Ctrl+Shift+Alt+F12 to open the
"symbol search" window. It might be a different combination depending on
your keyboard settings. It's also available from the menu Edit ->
Search&Replace -> Search for symbol. Enter "max" (without quotation marks)
and press <enter>.

Nov 20 '05 #2
..NET has System.Math.Max that will find the max of two numbers, you can
write a Max that accepts any number of numbers using a ParamArray parameter.

Something like:

' VS.NET 2003 syntax
Function Max(ByVal ParamArray values() as Integer) As Integer
Dim result As Integer = Integer.MinValue
For Each value As Integer In values
result = Math.Max(result, value)
Return result
End Function

Of course you can overload the above function for other types, such as Long,
Short, Byte, Single, Double, Decimal.

When we get VS.NET 2004 (Whidbey) we can write the above using Generics
which means the compiler will automatically overload for us!

Hope this helps

"John A Grandy" <johnagrandy-at-yahoo.com> wrote in message
does .NET have a Max() function ?

something like

MyMaxValue = Max(Value1,Value2,Value3,Value4)

Nov 20 '05 #3
* "John A Grandy" <johnagrandy-at-yahoo.com> scripsit:
does .NET have a Max() function ?

something like

MyMaxValue = Max(Value1,Value2,Value3,Value4)

You can build a function like this by using 'Math.Max' (compares two

Herfried K. Wagner
MVP VB Classic, VB.NET
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: pankaj_wolfhunter | last post by:
Greetings, Sorry if this questions is too basic. just wanna know if the max function in db2 gives the result based on the ascii value or in ascending order. I tried but not able to figure out the...
by: Robert | last post by:
When you use an aggregate function in a SELECT statement, you cannot specify any fields you want they way you usually can in a SELECT statement. Only fields that are part of the GROUP BY clause...
by: jj_frap | last post by:
I'm new to programming in Python and am currently writing a three-card poker simulator. I have completed the entire simulator other than determining who has the best hand (which will be far more...
by: james.eacret | last post by:
Hello all, I am stuck on a query, and was hoping for some help. I'm using Access 2003 with a WinXP machine. I need to find the Max value of a chemical, and also include SiteID,...
by: ismailj | last post by:
Hi, I'm using Weblogic 9.2 which uses Saxon 8.1.1 as its XQuery Engine. I'm using max function and in the argument I'm passing the node which has two dateTime values. It is giving exception. ...
by: ncsthbell | last post by:
I am trying to run a query in access using the 'max' function. For example, I have many rows of data, one for each state and each state has a column for 'Miles'. I want to get the highest number of...
by: omar999 | last post by:
I can use the select sql max function with no problems; this is my code SELECT MAX(Bid_Amount) AS LargestBidAmount FROM Auction_1 then to output using asp Response.Write "<td...
by: Stevestan1 | last post by:
I have a table with 3 columns. The columns are "Case Number", "Agent ID", and "Time the Agent Touched Case". There are multiple records of the same "Case Number" since a case can be touched by...
by: James Tran | last post by:
Hi, I've been trying to find and display only the maximum count of a field. I have two tables; STUDENT_TABLE - Student ID, Title, Surname and Christan Name. LESSON_TABLE - Student ID The two...
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.