472,338 Members | 1,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Extract MAX Number from Array

1
Hello,

I have an array of numbers where I am attempting to extract the highest (max) number in the array. I am pretty new to asp and vbscript and hope to get some help. My code below returns 22 as the max number though it should be 45. can someone direct me in the right direction?

Thanks



MyArray=Array(25,14,20,45,25,4,1,31,22,7)

For i=0 to ubound(MyArray)
For j=i+1 to ubound(MyArray)
if myarray(i) > MyArray(j) then
co = myarray(i)
end if
next
next

'Write the Highest number in MyArray
Response.write co
Nov 13 '06 #1
1 4714
willakawill
1,646 1GB
Hello,

I have an array of numbers where I am attempting to extract the highest (max) number in the array. I am pretty new to asp and vbscript and hope to get some help. My code below returns 22 as the max number though it should be 45. can someone direct me in the right direction?

Thanks



MyArray=Array(25,14,20,45,25,4,1,31,22,7)

For i=0 to ubound(MyArray)
For j=i+1 to ubound(MyArray)
if myarray(i) > MyArray(j) then
co = myarray(i)
end if
next
next

'Write the Highest number in MyArray
Response.write co
Hi. Try this
Expand|Select|Wrap|Line Numbers
  1. co = MyArray(0)
  2. For i = 1 To UBound(MyArray)
  3.    If MyArray(i) > co
  4.       co = MyArray(i)
  5.    End If
  6. Next i
  7.  
Nov 13 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

44
by: RB | last post by:
How to extract bytes from long, starting from the last byte? For example, I have a long number: 0x12345678 I need to represent it as the following...
6
by: Mohammad-Reza | last post by:
Hi I want to extract icon of an exe file and want to know how. I look at the MSDN and find out that I can use ExtractIconEx() Windows API but in...
3
by: David Moore | last post by:
Hi All, I expect someone can crack this one in no time. Ok, what I'd like to do is to match a pattern in a string and extract a portion of it....
8
by: Fabian Braennstroem | last post by:
Hi, I would like to remove certain lines from a log files. I had some sed/awk scripts for this, but now, I want to use python with its re module...
6
by: Ben | last post by:
Hi We have a Dataset that has been populated from the output parameter of a Stored Procedure (@Output). I understand that I can extract a...
5
by: =?Utf-8?B?aWxy?= | last post by:
Hi This is probably fairly simple but I am newish at programming and was wondering if someone can give me some advice on handling the following....
1
by: manishabh77 | last post by:
I will be obliged if anybody can help me with this problem: I am trying to extract data from an excel sheet that matches IDs given in column 4 of...
3
by: thesinnerishere | last post by:
this is regarding the last number standing problem. it requires the number in an array to be extracted at a specified position . then the array...
7
by: JoeC | last post by:
I am trying to create a windows program that reads binary graphics as a resource. This has nothing to do with win32 but conversion of data with...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

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.