|
Answer» Hello,
I started not so long ago with vb so i'm not really good with it yet, I got the assignment to insert a productcode like"12345A"(if it's not 6 character it shouldn't work either) and after pushing 1 button it NEEDS to show the price and how many there are in stock(this is 1 line STORED in the txt.file) this is what I got so far(oh yeah I only need to put in 10 lines of products into the txt.file)
Public Class Form1 Dim strartikel(10) As String Dim intteller As Integer Dim intteller1 As Integer
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load FileOpen(1, "E:\toi\bestanden\artikelen.txt", OpenMode.Input)
Do Until EOF(1)
strartikel(intteller) = LineInput(1)
intteller = intteller + 1 Loop FileClose(1) End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim strartikelnummer As String
strartikelnummer = CType(txtartikel.Text, String)
if strartikelnummer = strartikel(intteller1) rtxtartikel.Text &= strartikel(intteller1) & vbCrLf intteller1 = intteller1 + 1 else msgbox("wrong CODE") end if
End Sub
End Class spend some time SEARCHING everything up and found it myself (always looks like it's so easy afterwards)
Public Class Form1 Dim strartikel(2) As String
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim strartikelnummer As String Dim intteller1 As Integer
strartikelnummer = CType(txtartikel.Text, String) intteller1 = 0 rtxtartikel.Text &= "artikelnummer " & "prijs " & "aantal stukken" & vbCrLf Do While intteller1 < 3 If Mid(strartikel(intteller1), 1, 6) = Mid(strartikelnummer, 1, 6) Then
rtxtartikel.Text &= Mid(strartikel(intteller1), 1, 6) & " " & Mid(strartikel(intteller1), 7, 7) & " " & Mid(strartikel(intteller1), 14, 4)
End If intteller1 = intteller1 + 1 Loop
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Dim intteller As Integer
FileOpen(1, "G:\toi\bestanden\artikels.txt", OpenMode.Input) intteller = 0 Do While Not EOF(1)
strartikel(intteller) = LineInput(1)
intteller = intteller + 1 Loop
End Sub End Class
|