Hello Robin,
Thanks for reacting. You're right. It doesn't work fine, but does some
things good..;-)
The main thing is OK: read the required data from a record and put them in
the right textbox...
But the.. read another record.. no way. Must restart the program again
first.
Ray
Here's the code: (read from 2 files and soe Dutch language)
Imports Microsoft.VisualBasic.FileIO
Public Class Form1
Dim objparser As New TextFieldParser("o:\cmdb\data\imdata.csv")
Dim Personeel As New TextFieldParser("o:\cmdb\data\vbatl.csv")
Dim conf As String
Dim atl As String
'Na een klik op de button worden de records uitgelezen
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnZoek.Click
objparser.Delimiters = New String() {";"}
Personeel.Delimiters = New String() {";"}
Me.Button1.BackColor = Color.LightSkyBlue
conf = (TextBox1.Text)
atl = (txtOwner.Text)
If TextBox1.Text = "" Then
MessageBox.Show("Verplicht veld!", "Invoerfout",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Return
End If
Do While Not objparser.EndOfData
Dim strvelden() As String = objparser.ReadFields
'MessageBox.Show("Laptop " & strvelden(0) & " wordt gebruikt
door " & strvelden(3) _
'& " " & strvelden(2), strvelden(1))
If conf = strvelden(5) Or conf = strvelden(1) Then
lblLogical.Text = strvelden(1)
txtSnr.Text = strvelden(5)
txtOwner.Text = strvelden(3)
txtOS.Text = strvelden(6)
txtSoort.Text = strvelden(0)
txtType.Text = strvelden(4)
txtScan.Text = strvelden(7)
txtLogonuser.Text = strvelden(8)
End If
' ' Do While Not Personeel.EndOfData
' Dim mensen() As String = Personeel.ReadFields
' If atl = mensen(0) Then
' txtMedewerker.Text = mensen(2) & " " & mensen(1)
' End If
'Loop
Loop
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MessageBox.Show("Geen serienummer of Computernaam ingevoerd",
"Invoerfout", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return
Else
Do While Not Personeel.EndOfData
Dim mensen() As String = Personeel.ReadFields
If mensen(0) = txtOwner.Text Then
txtMedewerker.Text = mensen(2) & " " & mensen(1)
txtAfdeling.Text = mensen(4)
txtTelefoon.Text = mensen(3)
End If
Loop
End If
TextBox1.Text = ""
End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
lblLogical.Text = ""
txtSnr.Text = ""
txtOwner.Text = ""
txtOS.Text = ""
txtSoort.Text = ""
txtType.Text = ""
txtScan.Text = ""
txtLogonuser.Text = ""
txtMedewerker.Text = ""
txtAfdeling.Text = ""
txtTelefoon.Text = ""
Me.Button1.BackColor = Color.LightGray
TextBox1.Focus()
End Sub
End Class
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:fu******************************@comcast.com. ..
You said it works fine, but you have to debug to read another record? That
doesn't really sound like "works fine" to me. ;-)
If you want help with reading the file, you need to post your code. If
your code is huge, make a small example and post that. Please post it in
text format, don't copy it from Visual Studio and paste it into an
OutlookExpress message.
Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
-----------------------------------------------
"Ray" <ra*****@hacom.nlwrote in message
news:45***********************@news.wanadoo.nl...
>Hello World,
I made a Windowsform that reads data from a CSV file.
It works fine, but when I have read the data of a record I have to
re-Debug the form to read another record.
So when I put a new seek item in the textbox after I searched for an item
and click the seek button.. it seems it is doing nothing.
And also... what code can I use to genereate a messagebox message when a
seek item is not at all in the CSV file?
If ?????????? Then
MessageBox.Show("Item is not in the file..")
End If
Thanks for reading this
Ray