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

Ascending Numbers

i'm wanting to set a list of numbers into a text box, but they need to be ascending how do I do this

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Printing Numbers In Ascending Order (in A String)

My code below choses 10 numbers from 1 to 10 (same number not repeated twice).
The numbers are then listed in my picturebox, but I need to sort them in ASCENDING ORDER.

Any idea how I can do this?

Thanks for any help!

Public First As Integer, Second As Integer, Third As Integer, _
Fourth As Integer, Fifth As Integer, Sixth As Integer, _
Seventh As Integer, Eigth As Integer, Ninth As Integer, _
Tenth As Integer

Private Sub Command1_Click()
Dim Numbers As New Collection, a As Integer
Dim result As New Collection, temp As String


For a = 1 To 10
Numbers.Add a
Next a
Do While Numbers.Count
a = Int(Rnd * Numbers.Count) + 1
result.Add Numbers(a)
Numbers.Remove a

First = result(1)
Second = result(2)
Third = result(3)
Fourth = result(4)
Fifth = result(5)
Sixth = result(6)
Seventh = result(7)
Eigth = result(8)
Ninth = result(9)
Tenth = result(10)

Picture1.Print First & " " & Second & " " & Third & " " & _
Fourth & " " & Fifth & " " & Sixth & " " & _
" " & Seventh & " " & Eigth & " " & Ninth & " " & Tenth
End Sub

SQL Order Ascending
Can some one please tell me where to add this part:

into this sql statement:

Thanks in advance

Ascending Order (A-Z)
i am use MS Access... can anyone come out with a vb code to arrange letter from A-Z... pls help.... TKS in advance...

E.g. i have just key in a new Data in the DB... In the combo box, it will have the new Data. But it will not be in the Ascending order...

Sort By Ascending And Decsending
How can I have a macro button sort a column in ascesnding order and then descending order the next time the button is pressed. I would like to have it alternate each time the button is pressed.

Need a much detail as possible.

Thanks in advance

Ascending And Descending Orders

I have a text field that users enter a string of 4 numbers into. The numbers are then stored into a Integer Variable. I then need to change the number firstly into ascending order (eg: 2689) then descending order (eg: 9862).

Is there a function that will put the number into these orders?


Sort Ascending Using Group By??

I am trying to get the table that results from the following statement to sort the outcomes column in descending order. Can DESC be included in GROUP BY? If so, where does it go? I have tried ORDER BY outcomes DESC, but I get an error message saying I need the group by. I am using Sybase SQL Anywhere, and am very new to SQL...

SELECT DISTINCT name1, place, event_type,
DateFormat(date_of_event,'yyyy') As year,
SUM (outcomes) As outcomes
FROM event_results
GROUP BY outcomes, name1, place, event_type, DateFormat(date_of_event,'yyyy');

How To Make The Ascending In The Table
can i using recordset to set fields ascending??
or must be using SQL to set it?

If u know the answer Pls reply me faster !!
Thank you,

URGENT: Ascending And Descending
how should i ascend or descend numbers? example i have 4 text box the if i press command button it will show in label but in ascending form.. thanks

Ascending, Descending BEEP!
I have a button on a form that when pressed I want it to make and ascending beep noise and then descend back down in the same pattern. The code I have come up with just results in an infinite loop, so I would appreciate any help

vb Code:
Private Sub Command1_Click() Dim i As LongDo Until i = 1000i = i + 100BeepAPI i, 100Loop Do Until i = 100i = 1000 - iBeepAPI i, 100Loop End Sub

Making A List Box Ascending
any1 know a way of making a list box ascending through code. Like in league tables where the teams can change through the points i would like to do the same. can some1 plz help me. cheers ppl.

Ascending And Descending Arrays
I have a program that has names in ten text boxs. When I click on the two buttons that say ascending and descending the names are to be in ascending and descending order. Can someone give an example of how to do this.

What The Code For Ascending Order
what the VB code for ascending order.... tks...

What The Code For Ascending Order
what the VB code for ascending order.... tks...

If We Sort A-z In Ascending, The Outcome Is A-z Or Z-a?

Im creating a report from MS access where theres an option to sort the data in the ascending order interms of the last name of a person. If it sorted in the ascending order the outcome is from A-Z or Z-A?


moved to VBA board by johnminkjan

Edited by - johnminkjan on 5/29/2005 1:51:38 PM

Sort By Ascending Or Descending
How To Sort By Ascending Or Descending In ADODC Database ?

How To Get Array Values In Ascending Order.
Dear all ,
I have written the following program which is used to calculate the number of components and their names in an assembly file (solidworks, 3d modelling). But the array used in this program does not give values in ascending order. How to get a array values in ascending order.

For ex : a list box contains "n" No. of valuse, I need to extract all the values in ascending order, as it is listed in the list box.

How to get a array values in ascending order. ?


Sub main()
Dim swApp As Object
Dim SWConfig As SldWorks.Configuration
Dim SWRootComp As SldWorks.component
Dim Children As Variant
Dim SWChild As SldWorks.component
Dim ChildCount As Integer
Dim bOldSetting As Boolean
Dim bRet As Boolean
Dim SWModel As SldWorks.ModelDoc2

Set swApp = Application.SldWorks
Set SWModel = swApp.ActiveDoc
Set SWConfig = SWModel.GetActiveConfiguration
Set SWRootComp = SWConfig.GetRootComponent
Children = SWRootComp.GetChildren
ChildCount = UBound(Children)
'Debug.Print SWRootComp.Name
Debug.Print ChildCount
For i = 0 To ChildCount
Set SWChild = Children(i)

'SwCmp1InsNam = swChild.Name2
'SwCmp1InsNam1 = swChild.Name2
Debug.Print i
Debug.Print SWChild.Name
Next i
End Sub

Actual order


Result I am getting is


Last 3000 Records In Ascending Order

What can I have our client put in his query, in our VB app, to receive the last 3000 records only? What about the first 3000 records only?

Say the query as it stands now is:

Select * from Data where animal = 'dog'

and I just want the last, or first, 3000 records to show?

Thank you,

Help...How Can I Arrange My Records In Ascending Order?
Hi everyone,

I need your help... How can I arrange my records, in a MsAccess database, in ascending order so that whenever the datagrid displays them, they are in order. and also, whenever I add new records, how can I make vb arrange those records automatically? Hope you can help.


The Ascending Query Code Works....
Here's is the working code:

SELECT DataStudentBioAcademic.LastNameCandidate
FROM DataStudentBioAcademic
WHERE ((( DataStudentBioAcademic.LastNameCandidate) >= "A"))
ORDER BY DataStudentBioAcademic.LastNameCandidate;

This is the specific query code itself. Now, all there is to ge it fitting into the VB code and see how it goes. I want t thank everyone for their postings. I know I seemed difficul with all of this, but I'm still a BIG newbie with all of thi and I do appreciate your postings. I'll let you all know when get the Order button working.

Help... How Can I Arrange My Records In Ascending Order?
Hi everyone,

I need to know how to arrange my records in an MSAccess database in ascending order so that whenever I display those records on a datagrid, they are already arranged. And also everytime I add new records, How can they be arranged automatically?

Thank you..

Ascending/sort Order In Excel
 I need help in arranging the columns in ascending order.

Assuming i got 10 columns and 10 rows.

And i want to arrange in ascending order based on column "C". i,e when we arrange based on col "C" all the other columns in that row also arrange the same way as column "C".


Edited by - chand22 on 5/12/2003 2:22:06 PM

Sorting A Data File In Ascending Order
I need to sort a data file by a 2 character field in ascending order. The only info I could find on sorting is how to sort an array. Does anyone know the command I need to use? Any help would be greatly appreciated.

THANKS!!! 8^)

How Can I Sort Array Elements In Ascending Order?
How's everyone doing?

I just wanted to know if anyone can tell me how I can sort the elements of an array in ascending order. Thanks

MSFlexgrid Sort Ascending By Date And Time
I have a FlexGrid and need to sort a column with date and time that is pulled from a sql table in ascending order. The data in the column looks like this:

LastFeed 'Column Header
3/31/03 07:25:20 AM
3/28/03 08:26:21 AM
3/31/03 05:30:34 PM

I also need to highlight the dates if they are not the current date.

Is it possible to sort in ascending order with a column that is populated with both the date and time? If the dates were the same is there some way to then look at the time and sort in ascending order by time?

Thanks for your help.

How To Sort Descending And Ascending Columns Of Datagrid
hello all ...!

anyone can help me ?
I want to know how to sort descending and ascending columns of datagrid by click the columns header.

Thank You

How To Sort 4 Columns Of Data In Ascending Order?
Name1 Volume1 Name2 Volume2
A 18 B 100
B 59 C 43
D 356 C 248
E 160 B 20
A 215 D 133

How do i sort Volume1 and Volume2 in ascending order?
While sorting Volume1, it should include the values in volume2.
So while sorting Volume1, the alphabets in the name column should also change accordingly.

So the end product should look like this:
Name1 Volume1 Name2 Volume2
A 18 D 133
B 20 E 160
C 43 A 215
B 59 C 248
B 100 D 356

How do i write the code using Visual Basic to sort the data accordingly?
Note: i have 65536 rows in Name1,Volume1 and 65536 rows in Name2,Volume2
Can anyone help? Thanks.

Sort Ascending Data / Printing Charts
Hi there,
I've a workbook called ChBook. It gets data from 2 other workbooks via a VB program.
ChBook has 5 columns which must be sorted ascending according to column B
The amount of rows is variable and becomes more in the future. The amount of rows which are filled with data is known via a variable.

The following I want to program:
How can I select the cells in column B with a variable?
And how do I program a "sort" so all 5 columns will be sorted according to column B?
Can I get some tips for programming a print option for printing the charts in ChBook?

Another question:
How can I convert a number to a string? ... this must be simple but I can't find it.


Sorting A Recordset Ascending, By A Specific Field
This is probably really simple, but how do I sort a RecordSet Ascending, by a specific field.

The Query I am using is:

"SELECT server.Name, server.Location, server.Connections" & vbCrLf & "From server" & vbCrLf & "WHERE (Not (server.Location)=" & Chr(34) & Chr(34) & ");"

Im kinda assuming I place the ascending thing in the query (as you do with PHP), I want to sort by the field server.Connections

Thanks for any help you can offer.

Code For Ascending/Descending Order Of Records
I think this is the first time I've ever asked for code i general and specifically. I could use some help on figuring ou a code for ordering data in a database table through VB, sinc the database isn't in order when it comes through a form, but i in order in the actual table.

I say figure out because I would like to come up with the cod without too much help, since it would help me learn. But, an help, even a complete code, I would appreciate it very much.

TopValues Must Be Descending, But Records Must Be Shown Ascending
OK, this one is doing my head in. I am sure there must be an answer out there as it seems so elementary but I cannot get my head round it.

I have a VB app that accesses an Access database. I want to pick the last 10 records according to date/time. This requires me to set up a query using SQL that uses the TOP keyword. For this to work I must sort in DESCENDING order, otherwise it takes the FIRST ten records.

The problem is, the ten records that result from this need to be shown in ASCENDING order, i.e. earliest date first up to the last date in the recordset.

If I was doing this within Access it would be no problem, I would just do a query for the first bit then incorporate that into a second query (I think). However, I cannot do this in VB. I have a recordset that picks out the last 10 records but they are in descending order. I cannot work out how to do another recordset that picks the 10 from the first recordset and reorders them in ascending order.

I am sure it can be done quite easily but it escapes me at the moment. Anyone got any ideas? Ta.

Have fun!

Alex Middleton

ADODC Sorting In Ascending Order By A Field
I use VB6 and ADODC control
I want to sort the data in another field(named Stream) in ascending order whose field type is numeric. How and where can I write it? The control is set to the DataGrid. Pleae advise.
My code is like this:

Adodc1.Recordset.Filter = "subject_name='" & Combo1.Text & "' "

Sort Access Table Ascending, By Specific Field

Just a quick question and it should be fairly simple for the experts.

What I want to do is have a button on a form and when this button is clicked, it sorts an Access table in ascending order by the "Customer Number" field.

The database table is linked to the form through a data control link.

Any help would be much appreciated.

How To Decide Sorting Descending Or Ascending In A MS Hierarchical Flexgrid ?
MSHFlexgrid1.sort = 1 , Then, How can I command descending or ascending ?

Sort Ascending And Selecting A Recordset - DatGrid Control
using a DataGrid Control in VB, how would i have a collum sorted ascending, and also how would i have a recordset selected?

for example:

i want to find a certain person, i enter his name and i want his whole record selected or "highlighted" on the table

Edited by - vbstudentncn on 3/28/2006 7:24:35 AM

Another 100% Newbie Question. How Do I Open A Form With Data Ascending From Lastname?
HOw do i make a query or whatever so that i can have a button on a normal form that then opens up a form with my data fields in it
but have the record sets listed ascending from the last name of employees??
if anyone helps out, could you quickly run through how i do it. pretty please. if you told me the code i wouldnt know what to do with it! hehe


while im at my newbie questions

How do i make a Multipage Tab thing properly
i can make the grey box with the tabs at the top, and edit them accordingly
But i have no clue how to put my data fields inside the different pages. when i drag my fields onto the tab pages, it just literaly has been placed over the pages. its not going INSIDE the tab indexs

i have searched for this but literaly, the online vb help on micrososft is so bad because of a SLIGHT information overload

thank you soooo much for all your help today guys and gals
especialy thinker and GMan_NC and all to mention few

Sql Query In Access To Display Ascending With Null Values Rows Following It
I want to select and order records.
The problem is that the order by clause field has null values in it.
Suppose if i give a select query with a order by ascending, i find the nulll valued colums displayed first and then the ascending order works.

how to eradicate this problem in Access query, to display the ascending order values first and then the null valued rows.

The same things works good in Oracle, the ordered values in the first and then the null valued rows.

I need a sql query to do this in Access !!

Access 2003 Query Sort Field Non Ascending Or Descending
Hi everyone.

I have a select query to pull a field [Lockbox] from a table and sort it in a specific order (non ascending or descending).

The problem is, when there are no records with Lockbox it errors out, but when the are (unprocessed) Lockboxes it runs fine.

The SQL code is as follows:

SELECT tblGC100.Lockbox
FROM tblGC100
GROUP BY tblGC100.Lockbox, tblGC100.[User Name], tblGC100.[Date Stamp], tblGC100.[Time Stamp]
HAVING (((tblGC100.Lockbox)<>"0002691") AND ((tblGC100.[User Name]) Is Null Or (tblGC100.[User Name])=GetCurrentUserName()) AND ((tblGC100.[Date Stamp]) Is Null) AND ((tblGC100.[Time Stamp]) Is Null) AND (([Forms]![GC100 Data].[txtDate])=[tbl_GC1002].[Cash Deposit Date]))
ORDER BY IIf([Lockbox]="0406919",1,IIf([Lockbox]="0406946",2,IIf([Lockbox]="0406955",3,IIf([Lockbox]="0406968",4,IIf([Lockbox]="0406927",5,IIf([Lockbox]="0406979",6,IIf([Lockbox]="0406933",7,IIf([Lockbox]="0406990",8,IIf([Lockbox]="0409548",9)))))))));

My theory is that I didn't account for the Null value in the IIf statements which is returned when the criteria is not met.

What would I add to the IIf statements to account for this Null value?

Thank you and have a great weekend, Wheels

Edited by - wheels on 5/23/2008 12:50:19 PM

How To Search A Textbox For Numbers, And If Numbers Not Found Give Error (Solved)
Hi, how do I go about searching a textbox to see if it has numbers only, and if it has like letters and other characters that are not number give an error.


[SOLVED]FormatCurrency Returns Numbers As Text Instead Of Formatted Numbers
This seems as a really dumb question but..... why is it that numbers resulting from a calculation work perfectly BEFORE I format them as currency and DO NOT work as numbers after I have formatted them?

Code:frmDCashFlow.Text7.Text = Val(frmDCashFlow.Text4.Text) + Val(frmDCashFlow.Text5.Text) + Val(frmDCashFlow.Text6.Text) 'This returns a value... OK

frmDCashFlow.Text7.Text = FormatCurrency(frmDCashFlow.Text7.Text, 0) ' This returns numbers as text, that can't be used to calculate once formatted....

Why and how can I avoid this? The FormatCurrency function is supposed to return a numeric expression formatted as currency value.....

Thanks for any help


Edited by - vbprog1144 on 10/26/2004 1:00:34 PM

Converting String Numbers Into Real Numbers

I have a formula in VBA that searches through a table for corresponding results to the conditions I specified and sort the results into another table. My problem is that the data I use, which includes monetary values, seems to have converted them into string numbers (which include de $ sign as part of the characters and not only into a simple visual effect). It's a problem when I want to do mathematic operations with those monetary values. Is there a way to convert them into real numbers in my VBA code just before doing my maths with them? I tried to pre-format the cells before their extraction but it seems it isnt enough to really convert them.



Splitting Large Numbers Into Smaller Numbers
i want to divide a decimal into smaller decimals in an array form.
starting with 0.22335566
array(0) = 0.22
array(1) = 0.0033 or 3.3 *10-2
array(2) = 0.000055 or 5.5*10-4

can anyone help?
thanx a million

How Do You Convert Whole Numbers To Decimal Point Numbers?
I have this code and it adds 9+9 then divides by 4 which = 4.5 and places it in a text box, but it dosn't show the 5 after the point.

Code:a = 9: b = 9
 text(8).text = a+b
 text(8).text = text(8).text 4
 text(8).text = Format(text(8).text, "#.##")

Whats wrong here?

Bob K

Edited by - Bob K on 3/17/2005 7:17:06 PM

How To Add Numbers (5 Different Numbers-add Them One After Another From A File-it's The Dynamic Arra
How to add numbers (5 different numbers-add them one after another from a file-it's the dynamic array) to an array and how to get these numbers out of the array? -thanks detailed code please

Sorting Texts And Numbers As If It Was All Numbers

I have a list of appartement numbers. Sometimes it's written 102 or sometimes 102a and 102b.



Actually, if I record a macro to sort those valuesm it puts 104a and 104b at the end of the list, without considering them as numbers which are locally before 105. Note that it could be one, two, three or more digits. It would be a dynamic lenght. The letter too could be dynamic as well.

Is there a way to tell Excel/VBE to sort intelligently this list?




Sub Sorting()

Selection.Sort Key1:=Range("A16"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

Random Numbers--same Numbers/different Order
HI, I'd like to display 4 numbers randomly. I would like the same 4 numbers to be displayed each time the random code runs but in a different order each time.

I'v etried the ran() function but it doesn't quite do the job.

Any ideas?

How To Get Only The Numbers From A String Of Numbers And Characters?
anyone out there know how to isolate only the integers from a string like so...


note the varying length of the day and month values in the date examples....

thx for helping ^_^

Compare Numbers And Save Numbers
Hi pros,
set 1 52
set 2= 1325
Now i make a compare these two set of numbers.
if mid(set1,Acounter,1)<>mid(set2,Bcounter,1)then
set 1 first no.1 match with set 2 no.1 =right number
IF set 1 no.2 match with set 2 no.2 but at third position once it match will end the loop. How can i save the set 2 no.5 in fourth position?

Thank you.

Yahoo! Biztools
- Promote your business from just $5 a month!

Enter Numbers From A Set Of Numbers, But Only Allow It To Be Entered Once.
Hi all,

I am trying to make an app for work, what I want to do is

1. Create a list of numbers, no real order and they will be added to and removed from as well
2. I then want to add them in a form (similar to an excel spreadsheet) with text boxes as I need them and I should only be able to add them once, ie.. no duplicate numbers

I hope this is not too vague. Thanks



Generating Random Numbers, Whole Numbers Only
hello all!

I used this code to generate random numbers in VB:
Code:lRndNum = (65000 * Rnd)

where I wanted to produce a bunch of random numbers from 0 to 65000.
My problem is, I want to discard the decimal points in the generated random result.

I only want to have random numbers, whole numbers, that is, without the messy decimal point.

I hope you'll hear me out. Thanks!

Copyright 2005-08, All rights reserved