I am currently having a problem with Reading from a text file and then splitting into 2 listboxs. I am able to read from the textfile no problems, but the contents is not splitting up into the right listboxs. It always goes into one or not at all. At the moment I am getting the error: Conversion from string "F" to type 'Double' is not valid.
What I am trying to do is get the contents of the textfile split into a male or female category. Using M for male and F for female in the textfile. If anyone could help me, that would be fantastic.
Imports System.IO
Public Class Form1
Dim firstname(20), lastname(20), applicationdate(40), address(40), gender(40) As String
Dim totalM, totalF, grandtotal, M, F, loops As Single
Dim genderM(20), genderF(20) As Boolean
Dim itemcount As Integer
Private Sub btnRead_Click(sender As System.Object, e As System.EventArgs) Handles btnRead.Click
dlgImport.ShowDialog()
Dim waiting As StreamReader = File.OpenText(dlgImport.fileName)
Do While waiting.Peek <> -1
firstname(itemcount) = waiting.ReadLine()
lastname(itemcount) = waiting.ReadLine()
gender(itemcount) = waiting.ReadLine()
applicationdate(itemcount) = waiting.ReadLine()
address(itemcount) = waiting.ReadLine()
If gender(loops) = M Then
lstMDisplay.Items.Add(firstname(itemcount))
lstMDisplay.Items.Add(lastname(itemcount))
lstMDisplay.Items.Add(genderM(itemcount))
lstFDisplay.Items.Add(applicationdate(itemcount))
lstFDisplay.Items.Add(address(itemcount))
ElseIf gender(loops) = F Then
lstFDisplay.Items.Add(firstname(itemcount))
lstFDisplay.Items.Add(lastname(itemcount))
lstFDisplay.Items.Add(genderF(itemcount))
lstFDisplay.Items.Add(applicationdate(itemcount))
lstFDisplay.Items.Add(address(itemcount))
itemcount = itemcount - 1
End If
Loop
waiting.Close()
End Sub
End Class

New Topic/Question
Reply



MultiQuote







|