Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...