Thread: Output help

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0

    Output help


    This may seem dumb that i can work with stuff like arrays just fine but can't remember how to output lol.

    What i want to do is have a output like

    "Marks over 40" at the top and have the results all go under it, how do you do this?

    (If you need more detail i will give if someone asks)
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    289
    Rep Power
    44
    There are many different ways to output data. The simplest is the Debug.Print command. The code below outputs the data directly to the form.
    Code:
    Option Explicit
    
    Dim N%
    Dim PrtArray(0 To 5) As String
    
    Private Sub Form_Load()
        PrtArray(0) = "Marks Over 40"
        For N% = 1 To UBound(PrtArray)
            PrtArray(N%) = CStr((N% + 4) * 10)
        Next N%
    End Sub
    
    Private Sub Command1_Click()
        For N% = 0 To UBound(PrtArray)
            Print PrtArray(N%)
        Next N%
    End Sub
    J.A. Coutts
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0
    Originally Posted by couttsj
    There are many different ways to output data. The simplest is the Debug.Print command. The code below outputs the data directly to the form.
    Code:
    Option Explicit
    
    Dim N%
    Dim PrtArray(0 To 5) As String
    
    Private Sub Form_Load()
        PrtArray(0) = "Marks Over 40"
        For N% = 1 To UBound(PrtArray)
            PrtArray(N%) = CStr((N% + 4) * 10)
        Next N%
    End Sub
    
    Private Sub Command1_Click()
        For N% = 0 To UBound(PrtArray)
            Print PrtArray(N%)
        Next N%
    End Sub
    J.A. Coutts
    Thanks will report back if it works.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0
    Well my program works but i want to output so every person with marks under 40 goes under the "Under 40" same with over 40, but it repeats the "Under 40/50" again each time (If that makes sense)

    Here is the code the program got (Yes it's most likelys not very good but i really don't care lol)

    Dim snameArray(9) As String

    Dim iNumberArray(9) As Integer


    Private Sub cmdover10_Click()
    Dim sLoop As Integer
    Dim sTempInput As String
    Dim dValue As Double


    For sLoop = 0 To 9

    snameArray(sLoop) = InputBox("Please enter name " & (sLoop + 1))

    sTempInput = InputBox("Please enter score " & (sLoop + 1))
    dValue = Val(sTempInput)
    iNumberArray(sLoop) = dValue

    Next





    For sLoop = 0 To 9
    If iNumberArray(sLoop) > 40 Then
    picLazyOutput.Print " Marks over 40 ="
    Print (snameArray(sLoop)); Tab(20); (iNumberArray(sLoop))




    End If



    Next
    For sLoop = 0 To 9
    If iNumberArray(sLoop) < 40 Then
    picLazyOutput.Print " Marks under 40 ="
    Print (snameArray(sLoop)); Tab(20); (iNumberArray(sLoop))

    End If

    Next




    End Sub



    If anyone could help me do that, i would be very grateful.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    289
    Rep Power
    44
    When posting code in this forum, use the proper code tags. for simplicity, use a single 2 dimensional array instead of 2 separate 1 dimensional arrays. The code below uses 2 list boxes for output that are cleared before being displayed.
    Code:
    Option Explicit
    
    Dim MarkArray(1, 9) As String
    
    Sub CreateMarks()
        Dim N%
        For N% = 0 To 9
            MarkArray(0, N%) = "Name" & CStr(N%)
            MarkArray(1, N%) = Int((100 * Rnd) + 1)
        Next N%
    End Sub
    
    Private Sub cmdover10_Click()
        Dim N%
        Call CreateMarks
        List1.Clear
        List2.Clear
        For N% = 0 To 9
            If Val(MarkArray(1, N%)) < 40 Then
                List1.AddItem MarkArray(0, N%) & " = " & MarkArray(1, N%)
            Else
                List2.AddItem MarkArray(0, N%) & " = " & MarkArray(1, N%)
            End If
        Next N%
    End Sub
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0
    Thanks, but what does it look like when it's working (Not at the PC where the file is at)
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    289
    Rep Power
    44
    Originally Posted by ewan
    Thanks, but what does it look like when it's working (Not at the PC where the file is at)
    Sorry, but I don't understand the question!
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0
    Originally Posted by couttsj
    Sorry, but I don't understand the question!
    Like what does it look like when your actually running the program.

IMN logo majestic logo threadwatch logo seochat tools logo