Results 1 to 5 of 5

Thread: Trouble with Arrays Code!!!!!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Location
    Illinois
    Posts
    27

    Unhappy

    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
    I'm a MICKEY FAN

  2. #2

  3. #3
    Fanatic Member coox's Avatar
    Join Date
    Oct 1999
    Posts
    550
    Amen brother Martin!! Like it...

    Tappling, would you like fries with that?

    Nick Cook
    VB6 (SP6)

  4. #4
    Guest
    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.

  5. #5
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    258
    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
    Visual Basic 6 SP4 on win98se

    QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width