THIS IS FOR VISUAL BASIC 2005
ok so you type a 3 digit UPC number in the text box and you hit a button to see it that 3 digit upc is contained in the .dat file called products.dat
if it is contained then it lists the item in a seperate text box.
the products.dat file is set up as follows:
UPC
Descritpion
Price
UPC
Descritpion
Price
UPC
Descritpion
Price
UPC
Descritpion
Price
and so on.....
i need it to read one line at a time and enter the new item everytime you put in another upc. Its doing it once then will not do it again. Please help i am so stuck right now. Here is my code:
CODE
Option Strict On
Imports System.IO
Public Class Form2
Dim infile As StreamReader
Dim outfile As StreamWriter
Dim UPC As String
Dim Desc As String
Dim Price As String
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
infile = New StreamReader(OpenFileDialog1.FileName)
With OpenFileDialog1
.InitialDirectory = "C:\Documents and Settings\Michael J Fisher\Desktop\24070\CashReg\CashReg\products.dat"
.FileName = "prodcuts.dat"
.CheckFileExists = True
If .ShowDialog() = Windows.Forms.DialogResult.Cancel Then
MessageBox.Show("You have selected cancel so now the program will close")
End If
End With
End Sub
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
End Sub
Private Sub EnterButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnterButton.Click
Do While infile.Peek >= 0
UPC = infile.ReadLine
Desc = infile.ReadLine
Price = infile.ReadLine
If UPCTextBox.Text = UPC Then
Reciept.Text = UPC & Desc & Price
End If
Loop
End Sub
End Class
This post has been edited by jayman9: 26 Nov, 2006 - 01:59 PM