473,406 Members | 2,705 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,406 software developers and data experts.

How to find the largest number from a list of number in a textbox with a for loop?

1
I made a list of random numbers. From that list, how can I find the largest number and the corresponding month?
Oct 24 '13 #1
1 1851
Frinavale
9,735 Expert Mod 8TB
There are a number of different search algorithms that you can use.

Some of them depend on how you are storing the data. Most of them use some sort of loop...including for loops.


If you want to do a sequential search, you loop through every item starting at index 0 and going to the length of the items.

Pseudo code example:
Expand|Select|Wrap|Line Numbers
  1. let biggestValue be 0
  2. let currentIndex be 0
  3.  
  4. begin loop
  5.   get the item at the current index
  6.   if the current item is bigger than the biggestValue
  7.     Set the biggestBiggestValue to the current item
  8.   otherwise, do nothing
  9.   increase the current index
  10.   if the index is greater than the length of the items, exit the loop
  11. loop
Here is an example of a For...Next loop in vb syntax:
Expand|Select|Wrap|Line Numbers
  1.  Dim currentIndex As Integer 
  2.  Dim maxIndexOfList As Integer
  3.  maxIndexOfList = 9
  4.  
  5.  For currentIndex  = 0 to maxIndexOfList Step 1
  6.   'get the item at the current index
  7.   'if the current item is bigger than the biggestValue
  8.   '  Set the biggestBiggestValue to the current item
  9.   'otherwise, do nothing
  10.  
  11.   'note that the currentIndex is automatically incremented by the "step" value provided
  12.   'note if no Step is provided, it is assumed to be 1
  13.  
  14.   'note that the loop will end when the currentIndex value is greater than the maxIndexOfList value
  15.  Next
-Frinny
Oct 24 '13 #2

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

Similar topics

2
by: Keke922 | last post by:
I have to write a program that allows the user to enter a series of integers and -99 when they want to exit the loop. How do I display the largest and smallest number the user entered?
2
by: PHP2 | last post by:
do anyone here with more experience know where I can find largest Standard C++ library list? which URL is best source..
12
by: Tescobar | last post by:
Over one year ago somebody asked here: how to remove selected elements from list in a loop?. The answer was as follows: for( it = l.begin(); it != l.end; ) { if(...) it = l.erase(it); else...
6
by: JIM.H. | last post by:
How can I grantee that user enter only number in the textbox. If possible accept ","and "." in the number. Can I do this?
8
by: JIM.H. | last post by:
Hello, I am trying to allow only number in a textbox. I need to put it into database as double. So Convert.ToDouble should not fail. How should I do this? Thanks, Jim.
4
by: mustang07 | last post by:
I need this program to find all occurences of a name and display them. If I enter Palmer, I need it to display all the Palmers in the list. Can anyone help me Please. Thank You!! #include...
0
by: Rajgodfather | last post by:
I am getting the end couldn't error while validating xml file against xsd. The xml file looks perfect. XML: <event id="1"> <!-- Successful event. --> ...
3
by: nitin3 | last post by:
validation in vb.net email_id validation,name,mobile number,Telephone number,zip_code,address i want to all code the textbox
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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
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...
0
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...

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.