-
I need help writing codes for two programs
First program: write a code that sorts 10 boxes accending and decending order wheather it's letters, names or numbers.
Second program:I have to use the lost focus event to write a code that totals up nine boxes that are controled arrays, the tenth box should total the numbers entered into the 9 boxes.
Thanks
-
Based on this question and your others, you really should pay more attention in class.
-
Amen brother Martin!! ;) Like it...
Tappling, would you like fries with that?
-
Also try not to post everything 2 or more times, posting your question one time i enough.
Anyway here is a simle way to sort an array:
Code:
Private Function SortArray(vArray, Optional ByVal bDescending As Boolean)
Dim i1 As Integer
Dim i2 As Integer
Dim v1
Dim v2
For i1 = LBound(vArray) To UBound(vArray)
For i2 = LBound(vArray) To UBound(vArray)
If i1 <> i2 Then
If Not bDescending Then
If vArray(i1) < vArray(i2) Then 'Ascending
v1 = vArray(i1)
v2 = vArray(i2)
vArray(i1) = v2
vArray(i2) = v1
End If
Else
If vArray(i1) > vArray(i2) Then 'Descending
v1 = vArray(i1)
v2 = vArray(i2)
vArray(i1) = v2
vArray(i2) = v1
End If
End If
End If
Next
Next
End Function
Use it like this:
'Create array
Dim avArray(1 To 5)
avArray(1) = 2
avArray(2) = 3
avArray(3) = 6
avArray(4) = 2
avArray(5) = 1
SortArray avArray, False 'Ascending
'SortArray tArray, True 'Descending
'Print values
Debug.Print avArray(1)
Debug.Print avArray(2)
Debug.Print avArray(3)
Debug.Print avArray(4)
Debug.Print avArray(5)
And about the text boxes my advice is this: RTFM.
-
Like the teacher said
Code:
F200 400 0 <Enter>
RAX <Enter>
301 <Enter>
RBX <Enter>
200 <Enter>
RCX <Enter>
1 <Enter>
RDX <Enter>
80 <Enter>
E100 CD 13 <Enter>
R <Enter>
P <Enter>
ahhh never mind :)