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