Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Sort Array in Ascending Order
Author:
Joven M. Muana
E-mail:
Click to e-mail author
Submitted:
4/17/2007
Version:
VB6
Compatibility:
VB6
Category:
Mathematics
Views:
71769
This will show you how to sort an array data and display it in ascending order.
Declarations:
'you will need a FORM and a Command Button Option Explicit Dim A(20) As Integer Dim num, i, j, k, arr, temp As Integer
Code:
Private Sub Command1_Click() arr = 0 Print "Your array contains: " For k = 0 To num - 1 Print "A"; "("; arr; "):"; A(k) arr = arr + 1 Next k End Sub Private Sub Form_Load() num = InputBox("Intialize the size of your array:") For i = 0 To num - 1 A(i) = InputBox("Enter your array: ") Next i 'this will sort your array in ascending order For i = 0 To num - 1 For j = i + 1 To num - 1 If A(i) > A(j) Then temp = A(i) A(i) = A(j) A(j) = temp End If Next j Next i End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement