dmdougla Posted May 5, 2004 Posted May 5, 2004 I am trying to get this code to read from two textfiles and display them, but I am not getting anything in return. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click Dim eNumber As String Dim eName As String Dim eAddress As String Dim eSSN As String Dim pNumber As String Dim pFICA As Double Dim pGross As Double Dim pNet As Double Dim pDate As Date Dim pHolding As Double Dim temp1 As Double = 0.0 Dim temp2 As Double = 0.0 Dim temp3 As Double = 0.0 Dim temp4 As Double = 0.0 Dim sEmployee As String() Dim sPayroll As String() Dim pEmployee As String Dim pPayroll As String Dim objStreamReader As System.IO.StreamReader Dim objStreamReader2 As System.IO.StreamReader objStreamReader = New System.IO.StreamReader("C:\Employee.txt") objStreamReader2 = New System.IO.StreamReader("C:\Payroll.txt") pEmployee = objStreamReader.ReadLine() pPayroll = objStreamReader2.ReadLine() Do While objStreamReader.ReadLine = "***" With sEmployee eNumber = sEmployee(0) eName = sEmployee(1) eAddress = sEmployee(2) eSSN = sEmployee(3) End With Loop Do While objStreamReader2.ReadLine = "***" With sPayroll pNumber = sPayroll(0) pDate = System.Convert.ToDateTime(sPayroll(1)) pGross = System.Convert.ToDouble(sPayroll(2)) temp1 += pGross pHolding = System.Convert.ToDouble(sPayroll(3)) temp2 += pHolding pFICA = System.Convert.ToDouble(sPayroll(4)) temp3 += pFICA pNet = System.Convert.ToDouble(sPayroll(5)) temp4 += pNet End With Loop txtName.Text = eName txtAdd.Text = eAddress txtSSN.Text = eSSN lbxDate.Text = pDate lbxGross.Text = pGross lbxHolding.Text = pHolding lbxFICA.Text = pFICA lbxNet.Text = pNet txtGross.Text = temp1 txtHolding.Text = temp2 txtFICA.Text = temp3 txtNet.Text = temp4 End Sub Quote
Administrators PlausiblyDamp Posted May 5, 2004 Administrators Posted May 5, 2004 what is the Do While objStreamReader.ReadLine = "***" With sEmployee eNumber = sEmployee(0) eName = sEmployee(1) eAddress = sEmployee(2) eSSN = sEmployee(3) End With Loop bit supposed to be doing? you really should be reading into a variable otherwise it will just throw away the line it has read. Also you do not appear to be assigning anything to sEmployee either. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
dmdougla Posted May 5, 2004 Author Posted May 5, 2004 I changed some of it now how do I make a stucture. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click Dim eNumber As String Dim eName As String Dim eAddress As String Dim eSSN As String Dim pNumber As String Dim pFICA As Double Dim pGross As Double Dim pNet As Double Dim pDate As Date Dim pHolding As Double Dim temp1 As Double = 0.0 Dim temp2 As Double = 0.0 Dim temp3 As Double = 0.0 Dim temp4 As Double = 0.0 Dim pEmployee As String Dim pPayroll As String Dim sEmployee As String() Dim sPayroll As String() Dim objStreamReader As System.IO.StreamReader Dim objStreamReader2 As System.IO.StreamReader objStreamReader = New System.IO.StreamReader("C:\Employee.txt") objStreamReader2 = New System.IO.StreamReader("C:\Payroll.txt") pEmployee = objStreamReader.ReadLine() pPayroll = objStreamReader2.ReadLine() Dim pInt As Integer = 0 Do While (pInt < (pEmployee.Length - 1)) sEmployee(pInt) = objStreamReader.ReadLine() pInt += 1 Loop objStreamReader.Close() Do While (pInt < (pPayroll.Length - 1)) sEmployee(pInt) = objStreamReader.ReadLine() pInt += 1 Loop objStreamReader2.Close() txtName.Text = eName txtAdd.Text = eAddress txtSSN.Text = eSSN lbxDate.Text = pDate lbxGross.Text = pGross lbxHolding.Text = pHolding lbxFICA.Text = pFICA lbxNet.Text = pNet txtGross.Text = temp1 txtHolding.Text = temp2 txtFICA.Text = temp3 txtNet.Text = temp4 End Sub Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.