473,671 Members | 2,283 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(2 5,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 5056
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(2 5,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
12708
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 advance, Rita
6
10507
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 those changes like this : public static extern uint ExtractIconEx( string szFile,
3
1782
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 had apples(20) and pears(30)' how do I extract the '20' and '30'? ie. if the pattern is 'apples(??)', how do I expect the '??'.
8
2827
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 log files. The first file looks like: ...
6
2097
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 using this code: CType(objDataSet.Tables("MyTable").Rows(0).Item("MyField"), String)
5
2842
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 in it. 0-9 are related data, 10-19, 20-29 are related and so on. What is the best way of extracting groups of elements from the array into another array where each element is the related data or to extract say elements 0,1,5 from the first...
1
5061
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 array (@names). After I look for the match in this section of the code: if ($value=~/^$names$/), I want to write out only those rows that satisfy the above natch condition. But currently the code I have here writes out everything. How do I get it to...
3
1769
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 extracted number until there's the last number in the array. that number is the answer. for eg. if the specified position is 2 then in the array 1,2,3,4,5 it should go this way 1,3,4,5 1,3,5
7
2107
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 hinstance){ size = 32; bitData.clear(); void * p = NULL; // point to the data int end; BYTE data;
0
8474
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8819
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8597
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8669
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7428
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6222
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5692
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2049
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1807
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.