syntax error with histogram

  • 15 years ago
    I have this code that is supposed to represent numeric values in a histogram. I can do it with the numbers, but with the histogram I'm stumped:
    txtOutput.Text = "Rating" & vbTab & "Frequency" & vbCrLf

          Dim i, j As Integer
          For i = 1 To 10

             txtOutput.Text &= i & vbTab & vbCrLf

             For j = 1 To m_intResponses(i)

                txtOutput.Text &= "*"
             Next
          Next

    to list numbers in one column and astericks in the other. I think this is my not having a good grip on the vbTab / vbCrLf commands, but instead of getting

    Rating    Frequency
    1            *
    2            ****
    3
    4            **

    i get

    Rating    Frequency
    1
    *2
    ****3
    4
    **5

    any ideas ? thanks.
































  • 15 years ago
    You are placing a return before you print your  '*'.  Try something like this:

    Dim i, j As Integer
    For i = 1 To 10
        txtOutput.Text &= i & vbTab
        For j = 1 To m_intResponses(i)
            txtOutput.Text &= "*"
        Next j
        txtOutput.Text &= vbCrLf
    Next i










  • 15 years ago

    yes thanks. a misplaced carriage return, and it looks like the loops werent nested correctly. thankyou.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“In theory, theory and practice are the same. In practice, they're not.”