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>.
--
Armin

Nov 20 '05 #2
John,
..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)
Next
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
Jay

"John A Grandy" <johnagrandy-at-yahoo.com> wrote in message
news:u%****************@TK2MSFTNGP12.phx.gbl...
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
values).

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

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

Similar topics

2
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...
2
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...
6
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...
3
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,...
8
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. ...
3
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...
2
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...
8
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...
4
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...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...
0
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.