Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Find The Two Highest Number From The List

Hello all,

I just joined the forum and I am new to VB programming. I am trying to solve this problem, I hope you guys can help me.

Is there a function or a formula that can be used to display two highest numbers that has been typed in a text box.

1. Reads the number from the text box each time a button is clicked and then displays the two highest number whenever the second button is clicked.
Can anyone help me on this?

Thanks a lot in advance.

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Find Highest Number In 2d Array
im making a program where people can input the votes for an election.
the user votes their choice for primeminister.
they can choose from 5 candidates.
they chose who to be as their 1st Choice, 2nd Choice and so on to 5th

after ive added the data into a 2d array i need it to calculate whether its an ABSOLUTE majority, a TIE or a RECOUNT is needed.

absolute majority is when more than half of the number of voters have chosen one candidate, and a recount is needed if a clear winner is not present.

i cant really explain what i need to be done but would really appreciate anybody who can help me and has msn messenger so i can further explain what i need and currently have

Find Highest Number / Access
Hi there. I have a little problem I'm working on.
It seems that the data I'm working with has a list of customers and customer numbers (which are unique) and then theres a CustID primary key.
Since Access wont let me convert the customer number to autonumber (and then make it a primary key) I need to figure out through some kind of query what the highest customer number is.

I am using VB6 and Access97 with ADO and using SQL queries to get my info from the database.

The table is Customer and the column I'm working with is CompanyNum

Something like

Option Explicit

Private Sub SomeCommand_CLick()

Dim rs As New ADODB.Recodset, SQL As String
Dim intMyNumber As Integer
SQL = "SELECT Customer.CompanyNum FROM Customer ORDER BY

and then

rs.Open SQL, etc.. etc..

If not rs.BOF or rs.EOF then
End if

intMyNumber = rs!CompanyNum

End Sub

Is that anywhere close?

How To Find Highest Number In A .txt File ???

I've got a question (again ). Is it possible to search a .txt file (C:/Test.txt)
for the highest and the lowest number in it ?? .
it only needs to search the numbers that are between < and >

Ex: <number>

I've googled it, but i couldnt find anything usefull

Find The Highest Number In A Recordset?
How do I find the hightes number in a recordset?

rsSales!SalesNumber ' Numeric - long integer

How do I find the highest Sales Number?

Search Through A Directory And Find The Highest Number In A Filename
Editted with newest post:

I looked around more on Google and found some code which I changed around a little. Here's that code, beneath it is the problem:

VB Code:
Dim imageLoc As String    Dim ImgTot As Integer    Dim fileList() As String    Dim fName As String    Dim I As Integer        imageLoc = "C:DBImages" & Me![In_CN] & ""        fName = Dir(imageLoc & "*.jpg")     While fName <> vbNullString        'add fname to the list        I = I + 1        ReDim Preserve fileList(1 To I)            fileList(I) = fName        'get next filename        fName = Dir()    Wend        ImgTot = UBound(fileList)

That will find all the images (*.jpg) in the correct directory and call that number ImgTot. The only problem is that if there is a file that isn't a consecutive number it counts that in ImgTot. I just want the 100% numeric filenames to be included in ImgTot. How would I go about doing that?

What I want:

When the user clicks the 'create' button it will search that same specified folder and automatically set a variable (imageNum) to the number of images in that folder (which is simply the highest numerical value in any filename in that folder. Filenames with anything but a number are disregarded.) that have a numerical name ([1, 2, 3...].jpg). Any other images (DSCN13401.jpg, DSCN4687.jpg) would be disregarded and not included in ImgTot.

How would I go about that process? Keep in mind I already have the image display system and the word document creation, hopefully you could provide me with search code and I could mold it to what I have.

Finding The Highest Number Inside A List Box

I have an assignment where I have to input 10 numbers through an Input box(which I have coded already and is working) and now I have to code the command button to find the highest number inside that list box.

Sorry for the stupid question, but I'm lost on where I have to go from here.

How Do I Sort 6 Labels So That The One With The Highest Number Is Highest?

I have 6 labels and 6 lines in a text file.
The text file is like:


Now, How do I get each one of these into a label, with the one with the highest first number at the top, and going down from that.

e.g labels:


Im figuring i need a do until eof(1) loop, getting each line into an array box. Then, I can split that line, with the deliminator as "/". However I do not know how to put the highest into the 1st label, and so on?

Any help?

Getting A String In Order From Lowest Number To Highest Number

Say I have 3 numbers between 1 and 10 inclusive, none to be the same as the other:

Dim numbers_got As Boolean


a = Int(Rnd * 10) + 1
b = Int(Rnd * 10) + 1
c = Int(Rnd * 10) + 1

If a <> b Then
If a <> c Then
If b <> c Then

numbers_got = True

End If
End If
End If

Loop Until numbers_got = True



How can I get text1.text to print the numbers in ascending order? In reality I actually have about 15 numbers, so it would be a bit impractical to have loads of

If a<>b then
if a <>j then ....etc....

Thanks for any help.

How To Find String/Number In Given List?

How to find whether a given string or number, in a set of strings/numbers.

For ex:

dim aa = "abc"

'--inlist function not available in VB, but I just used for example.

if inlist(aa, "acc","abb","acc",...) then
msgbox aa & "is in list"
1. Given list may contains many strings/numbers
2. I expect, return value of boolean.
3. What is the equivalent function for 'inlist' here.

Highest Number
Im trying to think of a way of doing this, briefly explained :
i wanna read the typed urls from the registry, which are named url1 url2, when i browser in my browser i wanna add the url to the registry, but i want to like, if there were five urls already in the registry, url1, 2,3,4,5 etc, i wanna add url6, like get the highest number from the string, anyone know anyway of doing this?


Find A High And Low Number In A List Of Numbers
I got a list of numbers in a whole bunch of textboxes. When I hit a the calcualte button, I would like for the high and low number to be displayed in two separate textboxes. Can anyone help me out with this please..... Justin ,,,,,,

Finding The Highest Value Number
suppose i had 3 numbers in three textboxes, how can i find the number with the highest value? is there a MAX function in VB?

Thanks for any insights


What Is The Highest Number A Text Box Can Have?
What is it?!?!?!
At 317 you get error 28 but that not the number.

Finding Highest Number?
In VB 6.0

If I enter 3 numbers into seperate text boxes, what code could I use to figure out which is highest?

I can compare 2 numbers and get the answer but when I attempt to do 3 numbers it never works.

Thanks in advance.


Rounding To Next Highest Whole Number
Does anyone know of a function or a method that I can use to round a number up to the next highest whole number? If I have, for example, 3.2, I want it to round to 4 and if I have 3.8 I want it to round to 4. I've looked around and asked around and can't find any ways of doing this.

Highest Number In Array
Does anyone know how to find the highest number in an array?

Display The Highest Number
say, number1=100, number2=200, number3=300
how can u display the highest number amongst the 3 text.
in clipper programiing syntax is... max(number1,number2) return is number2


Find Highest Value In Flexgrid
i need to find the highest value in my flexgrid

is there an easy way to loop through each column and find the highest value for each?

thanks in advance

Displaying Highest Number In An Array
hey guys, me again. attempt number 2 on trying to get to the bottom of these arrays. i'm trying to display the highest number in an array and i am using the following code. can anyone tell me why it keeps giving me a result of zero. i have been searching through the forum and this was basically what i came out with.

(I can fill the array as i have a button that displays the numbers inputted into the array)

VB Code:
Private Sub cmdHighest_Click()Dim Highest As IntegerDim Numbers(1 To 5) As Integer  For Index = 1 To UBound(Numbers)       If Numbers(Index) > Highest Then       Highest = Numbers(Index)    End IfNext Index  lblHighest.Caption = Highest  End Sub

How Can I Record Highest Random Number...

I have a label,timer and button on my form. The timer generates a number every second from 1 to 100. The button enables the timer. The number is then placed in the label. What I want to do is every time a higher number appears than the one before I want that to go in, but I don`t want it to go down again for a lower number.

Is there a way you can do this??



Find Highest To Lowest, Listbox
i have a bunch of different size numbers in a listbox, they will be different each time.
what i want to do is put all the numbers into an array from the highest to the lowest.

any ideas ?

thank you

SQL Stateent To Find 5th Highest Salary
Please send me the SQL Statement to find the Employee row who is getting the 5th highest salary?


Check Array Values For Highest Number
I have an array with 4 slots

Dim x(3)

I need to check the array to make sure at least 1 of the numbers in it is higher than all other numbers.

What is the most efficient way to do this?

Finding The Highest Number In A Directory... STILL UNRESOLVED
We are currently building a package which places each estimate number into a file like this...


I have programmed a listview to read-in all the files in the estimates directory... but you have to give it a number from at to... IE.

For Intx = 0 to 25000

The question being... how can i search the directory for the highest number of file to that number can replace the 25000 in the example. The trouble is, when the user enters a number 25001... it won't find it.

I can't set the number to 10000000 before anyone it would take weeks to open the program.

Any help would be much appeciated.



Using VB To Find Highest And Lowest Values Out Of Dataset
hi everyone,

for my IPT assignment i have to create a program that allows members of a cricket board to enter the ten batting scores and for it to output the highest score, lowest score, and average score. I am able to output the average score that easy, but am having difficulty trying to create the program to output the highest and lowest scores. It is probably very simple....




How To List Highest Score In A Game?
I want to display scores which will be displayed ascending...Highest score then the next highest score and etc...

How To Find Hard Disk Model Number & Microprocesser Number?
How to find hard disk model number & microprocesser number.
Is there any API through which I can find out these numbers.

Set Next Number Of Combo Box List According To The Number Pressed
im trying to make a smart combo box that will loop through itself when KeyPress is activated and set the number that is pressed.

i have a combo box with years loaded in it ranging from 1930 to 2005. when the user will press 1 it will automaticly go to the first number starting with one wich is 1999, then if the user will press 8 it will go to 1899 and so on.

just for the combo box style is set to "2 - Dropdown List"

i have tried doing this myself but i dont see where im going with this , so maybe you can help me.

this is where im stuck

Private Sub cboYr_KeyPress(KeyAscii As Integer)
Dim i As Integer
Dim srch As Byte
If KeyAscii >= 48 And KeyAscii <= 57 Then
For i = 0 To cboYr.ListCount - 1
If KeyAscii = cboYr.List(i) Then cboYr.Text = cboYr.List(i)
Next i
For srch = 1 To 5
For i = 0 To cboYr.ListCount - 1
If cboYr.List(i) = KeyAscii Then
cboYr.SelStart (srch - 1)
End If
Next i
Next i
End If
End Sub

thanks for your time!

Find A Number..
i couldnt really explain well in a title..but i want to know if a string contains a number that i can do something..i dont think isnumeric works here..any ideas?

Find Number
Hi All, Again,

How can I find a number from a string i.e. I have a text field with "hell12o" and I want a interger to have the value 12 the text field could be any text or number.



How To Find % Of A Number
I Have 3 text boxes the first text box the user will put in the % of the number the second text box will be the number to get the % from and the third will be answeer of text 1 and text 2.

What I need to know is how to do % of a number in
Visual Basic

Thanks in Advance
Donny S.

.Find For The Exponential Number
Hi All,

I am trying to work with the cell containing the minimum value from a range. I have the code working fine except for when I try to deal with transendental numbers (such as pi), which it cant register exactly (Stupid floating points!)

I've got a way around it with the code below, but just wondering if someone can astound me yet again with a better method!

Sub FindCell()
'Other Code Here

MinNum = Application.WorksheetFunction.Min(rngUse)

Set rngMin = rngUse.Find(what:=MinNum, lookat:=xlWhole)

If rngMin Is Nothing Then
Set rngMin = ClosestCell(MinNum, rngUse)
End If

'Other Code Here
End Sub

Function ClosestCell(MinNum As Double, rngTot As Range) As Range
Dim rng As Range
Dim Min As Double
Dim Diff As Double

Min = 1
For Each rng In rngTot
Diff = Abs(rng.Value - MinNum)
If Diff < Min Then
Min = Diff
Set ClosestCell = rng
End If
Next rng
End Function

Any help greatly appreciated!


How To Find Week Number?
I am trying to calculate the week number of a given date. I am using:

where k3 is the date in question
and L2 is a cell with the first day of the year (eg 01/01/2004)

This works, but what I would really like is some way of generating the value in L2 automatically.
So, the problem is this, how can I automatically return a date that represents the first of january of the current year, without using VBA?

Any ideas?

Find The Largest Number
I have to make a loop statement that will read a file full of integers such as.

etc, and A message box must pop up telling the user the largest number in the file. I thought it would be easy because all you had to do was read the file and find out what's already in there, but it must work on any file full of numbers.

Can someone help me to get started, perhaps with some pseudocode?

Im really stuck and so far, I cannot make it work.
I will post again as soon as I at least have something worth posting.

Find The Number Of Char
I have a text file that contains a LONG sentence with about 10 commas separating certain fields, (CVS). I want to get the value after lets say comma 5 and before comma 6 , is there a easy way to do this?

Trying To Find Number Of Records.....
i'm using a access database and i'm trying to find out how many records are in a table using vb. does anyone know how i would go on about doing this??

Can't FInd Reason For Err.Number
VB 6 Enterprise

See below for explanation:

This code is under a Command Button

If DeleteContract Then
SQL = "Select * from PercentTable where dbPercentContractNumber = '" & txtContractNumber.Text & "';"
Call OpenPercentTable ' Open Percent Table
Call GetPercentTable ' Get Records needed based off of SQL statement
If rstPercentName.RecordCount = 1 Then
Do Until rstPercentName.EOF
End If
Set dbgPercent.DataSource = rstPercentName
End If

Public Sub OpenPercentTable()
Set pcmdPercent.ActiveConnection = pconTracking
pcmdPercent.CommandType = adCmdTable
pcmdPercent.CommandText = "PercentTable"
Set rstPercentName = New ADODB.Recordset
rstPercentName.LockType = adLockOptimistic
rstPercentName.CursorLocation = adUseClient
rstPercentName.CursorType = adOpenKeyset
rstPercentName.Open pcmdPercent
End Sub
Get the Records needed

Public Sub GetPercentTable()
On Error Resume Next
rstPercentName.Open SQL 'See below NOTE # 1
If Err.Number = 3705 Then
Call OpenPercentTable
rstPercentName.Open SQL
Err.Number = 0
On Error GoTo 0
End If
End Sub
When I go to GetPercentTable
NOTE # 1: After this statement is executed, ERR.Number = 3705 and Err.Description says "Operation is not allowed when object is open."

So then I close the Table, call OpenPercentTable, re-issue the open. The rstPercentName.RecordCount equals ALL the records in the table (584). I should only have 3. Here's my SQL statement:
Select * from PercentTable where dbPercentPONumber = 'TY' order by dbPercentContractNumber

I don't understand why I am getting ALL THE RECORDS? When I test the SQL statement using Visual Data Manager, it works great. I get my 3 records.

Find A Digit In A Number
Hi to all:

I need to find a digit in a number like:


For example: I need to find the 5 digit (,) through a instruction

How can I do this?


Control For Find Tel Number
Do you know a free control for VB for :

It can find Tel number before hang off .


Find Next Consecutive Number
I have a ADO datastore which links to a field of numbers.

What I want to do is to scroll through the set of numbers and either ..
a. Find gap in the set
b. Find the next number in the set


1, 2, 3, 4, 6, 7, 8
I want 5 returned

otherwise, if

1, 2, 3, 4, 5, 6, 7
I want 8 returned

Number Of Record With Find
VB Code:
adors.Find "Staffno LIKE  '*" & Left(TxtEE.Text, 11) & "*' "

I need to know the number of records find upon adors.find and to have a MsgBox to show find number of record.

VB Code:
if adors.Find > 0 Thencondition1 Elsecondition2End If

The above code is incorrect. Does anyone know how to do it?
I can't use recordCount as RecordCount willl abtract number of record from SQL Select Statement.

THank you in at advance

How To Find System Number?
How to distinguish from one system to another? Is there any universal key for each system? if so how to find that system key for that system.. I want to use this in my code... please help me in this regard....

eagerly waiting for your favourable reply


How To Find Multiples Of A Number Using VB?
hi,i am learner.please tell me how to find multiples of a number using VB5.0.
thank u.

Find Version Number Of An .exe

I my vb6 application I call several external applications. On my About form I want to show the version number of these external applications. How can I get these applications version numbers.

Thanks for the help,

Dale Williams

How To Find A Number In A String?
How can I find the first occurence of a number starting on the right side of a string moving to the left? I know about the right function.

Any ideas?


How To Find A Number In A String
How to find a number in a string?
When i get a string :
mystring = "jkj kj j jjjk 4.235kkik"
i want
mynumber = 4.235

The number doesn't always stand on the same place
in the string.


Hot Ot Find And Give Number...
i have datagrid1 and data.dbf file...

Dim ConAkt As ADODB.Connection
Dim RecAkt As ADODB.Recordset
Set ConAkt = New ADODB.Connection
Set RecAkt = New ADODB.Recordset
Dim sq As String
sq = "SELECT * FROM data.dbf ORDER BY NR"
ConAkt1.Open "Driver={Microsoft dBASE Driver (*.dbf)};" & _
"DriverID=277;" & _
RecAkt.Open sq, ConAkt, adOpenStatic, adLockOptimistic
If RecAkt.BOF = True And RecAkt.EOF = True Then

Set DataGrid1.DataSource = RecAkt

i wanna in data.dbf file - column name "NR" give number all records but only one number to records who have the same value "NR" how to make this ??

How Do I Find The Nearest Number?
I have another problem with Access, i want to find a row based on the closest number i.e.

these are my numbers, they are set but there is no set pattern to them:


my problem is , if someone puts in 150 in the [Page Count] field, i want it to put 145 in the [Counter] field because this is the closest number

I used to use INDEX() and MATCH() on Excel but of course this does not work with Access


Find Closest Number
Need to find the closest number to numbers in one table to the list of numbers in another table (ms access). I was able to do this in a query for a small table but when I got to 10,000 records it runs for hours without returning any records. I am drawing a blank on how to do this in code. I believe code would do it quickly. Thanks for any ideas.

Copyright 2005-08, All rights reserved