trouble with Visual Basic
I just need to format the number for the the vkilled and vinjured and then format the percent for the vtkilled and vtinjured and I forgot how to do that. I attach the file of what I want my ressult to look like. I am really close I just need to finish it up and I am not sure how. and if you see something wrong in my code that won't make it look like the file please let me know. I know I am close just not sure what I really have to do. Thanks steve T
Visual Basic:
Dim vftornado As String
Dim vstate As String
Dim vcounty As String
Dim vkilled As Integer
Dim vinjured As Integer
Dim vtinjured As Long
Dim vtkilled As Long
Dim fmtstr As String = "{0,-13}{1,-13}{2,12:n0}{3,10:p1}{4,12:n0}{5,10:p1}"
Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
FileOpen(1, "Tornado.txt", OpenMode.Input)
Do Until EOF(1)
Input(1, vftornado)
vkilled = vftornado.Substring(24, 2)
vinjured = vftornado.Substring(29, 3)
vtinjured = vtinjured + vinjured
vtkilled = vtkilled + vkilled
Loop
FileClose(1)
lstout.Items.Add(String.Format(fmtstr, "State", "County", "Killed", "%Killed", "Injured", "%Injured"))
FileOpen(1, "tornado.txt", OpenMode.Input)
Do Until EOF(1)
Input(1, vftornado)
vkilled = vftornado.Substring(24, 2)
vinjured = vftornado.Substring(29, 3)
vstate = vftornado.Substring(0, 12)
vcounty = vftornado.Substring(12, 11)
lstout.Items.Add(String.Format(fmtstr, vstate, vcounty, vkilled, vtkilled, vinjured, vtinjured))
Loop
End Sub
End Class
Attachments
Last edited by a moderator: