It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

Need Some Help

Moderator: dafunkymunky

Need Some Help

Postby Cr1pPl3r on Wed May 30, 2007 2:51 pm

I keep Geeting a FormatException was not handled error Input string not in correct format when I hit the button to display my output. It happens on the First
ListBox1.Items.Add(String.Format(fmtstng, Group, Male, Female, Male2, Female2, Total3)) Line. Anybody have any Ideas



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Pop As IO.StreamReader = IO.File.OpenText("populationdata.txt")
Dim Group As String
Dim Male, Female, Total, Male2, Female2, Total2 As Double
Dim Total3 As Double
Dim fmtstng As String = "{0,-15} {1,14} {2,13} (3,12:p} {4,11:p} {5,10:p}"

Group = Pop.ReadLine
Total += CDbl(Pop.ReadLine)
Total += CDbl(Pop.ReadLine)
Group = Pop.ReadLine
Total += CDbl(Pop.ReadLine)
Total += CDbl(Pop.ReadLine)
Group = Pop.ReadLine
Total += CDbl(Pop.ReadLine)
Total += CDbl(Pop.ReadLine)
Pop.Close()
ListBox1.Items.Add("Age Group Females %Males %Females %Total")
Pop = IO.File.OpenText("populationdata.txt")
Group = Pop.ReadLine
Male = CDbl(Pop.ReadLine)
Female = CDbl(Pop.ReadLine)
Total2 = Male + Female
Male2 = Male / Total2 * 100
Female2 = Female / Total2 * 100
Total3 = Total2 / Total * 100
ListBox1.Items.Add(String.Format(fmtstng, Group, Male, Female, Male2, Female2, Total3))
Group = Pop.ReadLine
Male = CDbl(Pop.ReadLine)
Female = CDbl(Pop.ReadLine)
Total2 = Male + Female
Male2 = Male / Total2 * 100
Female2 = Female / Total2 * 100
Total3 = Total2 / Total * 100
ListBox1.Items.Add(String.Format(fmtstng, Group, Male, Female, Male2, Female2, Total3))
Group = Pop.ReadLine
Male = CDbl(Pop.ReadLine)
Female = CDbl(Pop.ReadLine)
Total2 = Male + Female
Male2 = Male / Total2 * 100
Female2 = Female / Total2 * 100
Total3 = Total2 / Total * 100
ListBox1.Items.Add(String.Format(fmtstng, Group, Male, Female, Male2, Female2, Total3))
Pop.Close()





End Sub
Cr1pPl3r
 
Posts: 0
Joined: Wed May 30, 2007 1:22 pm

Who is online

Users browsing this forum: No registered users and 2 guests