Formatting output in VB


New member
Ok, so I have this set of data and everything, but I want to format the numbers into percentages and actual numbers. I tried doing this in the "fmtStr" by putting a
after the numbers but it does nothing. Anyone know why?

    Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
        Dim fmtStr As String = "{0,-10}{1,12:N0}{2,14:N0}{3,12:N0}{4,14:N0}{5,14}"

        With lstGender.Items
            .Add(String.Format(fmtStr, "Age Group", "Males", "Females", "%Males", "%Females", "%Total"))
            .Add(String.Format(fmtStr, "Under 25", "51210", "48905", "51.15", "48.85", "34.80"))
            .Add(String.Format(fmtStr, "25-64", "74169", "77059", "49.04", "50.96", "52.56"))
            .Add(String.Format(fmtStr, "65+", "15319", "21051", "42.12", "57.88", "12.64"))

        End With
    End Sub
End Class

EDIT: Idiot, I think I know what I did. I put the numbers in quotes too, so that changed them to string values and strings aren't touched with formatting.
Last edited:
Yeah that was what did it. I just kept going with the quotes because I started out with them.