473,511 Members | 16,864 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extract MAX Number from Array

1 New Member
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 5005
willakawill
1,646 Top Contributor
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
12632
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 bytes list: 0x78, 0x56, 0x34, 0x12 Thanks in...
6
10493
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 there are some changes to that api in c# I made...
3
1768
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. For example if I had a string like: 'The store...
8
2817
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 for this task. Actually, I have two different...
6
2091
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 single item when the dataset is populated by a table...
5
2832
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. I have an array with a large number of elements...
1
5052
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 the excel sheet.I have stored those query IDs in an...
3
1765
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 needs to traverse through the right position of the...
7
2100
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 memcpy. graphic::graphic(UINT uiResID, HINSTANCE...
0
7242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7138
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
7355
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7423
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7510
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
447
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.