My project is almost done!
For now I have this question:
My code is reading line by line and the result is showing in another form within my app. That's ok, but only one thing that I don't know how to change.
Case "TEL;WORK;VOICE"
strTelWerk = strWaarde(1)
sbBuilder.Append(strWaarde(1) & vbTab)
The Code above: The line "TEL;WORK..etc is 2 times in the file..
Now I want to delete the line if the line is in that file already.. so if the line exist than delete and go to next line.
This is the code:
Private Sub Importeren() _
Handles itemImporteerVCard.Click, mnuImportVCard.Click, btnImportVCard.Click
Dim strBestand As String = String.Empty
Dim strRegel As String = String.Empty
Dim strWaarde() As String = Nothing
Dim objReader As System.IO.StreamReader = Nothing, sbBuilder As System.Text.StringBuilder = Nothing
Dim strNaam As String = ""
Dim strVoornaam As String = ""
Dim strTelWerk As String = ""
Dim strTelThuis As String = ""
Dim strMobiel As String = ""
Dim strOverig As String = ""
Dim strFaxWerk As String = ""
Dim strFaxThuis As String = ""
Dim strAdres As String = ""
Dim strUrlThuis As String = ""
Dim strUrlWerk As String = ""
Dim strMail As String = ""
Dim boolFlag As Boolean = false
If MsgBox("Wilt u een v-Card Importeren?", 36, "Bevestiging voor het importeren") = MsgBoxResult.Yes Then
Try
strBestand = "C:\Test.vcf"
sbBuilder = New System.Text.StringBuilder
frmVCard.txtVCard.Text = strBestand
objReader = New System.IO.StreamReader(strBestand)
ofdImport.Filter = "V-Cards (*.vcf)|*.vcf"
ofdImport.FileName = "*.vcf"
ofdImport.Title = "V-Card importeren"
If ofdImport.ShowDialog = System.Windows.Forms.DialogResult.OK Then
objReader = New System.IO.StreamReader(strBestand)
frmVCard.Show()
End If
Do While objReader.Peek >= 1
strRegel = objReader.ReadLine()
strWaarde = strRegel.Split(":")
Select Case UCase(strWaarde(0))
Case "BEGIN", "VERSION", "END"
Case "N"
strNaam = strWaarde(1)
sbBuilder.Append(strWaarde(1) & vbTab)
Case "FN"
strVoornaam = strWaarde(1)
sbBuilder.Append(strWaarde(1) & vbCrLf)
Case "TEL;WORK;VOICE"
If boolFlag = false
Then
strTelWerk = strWaarde(1)
sbBuilder.Append(strWaarde(1) & vbTab)
boolFlag = true
End If
Case "TEL;HOME;VOICE"
strTelThuis = strWaarde(1)
sbBuilder.Append(strWaarde(1) & vbCrLf)
Case "TEL;CELL;VOICE"
strMobiel = strWaarde(1)
sbBuilder.Append(strWaarde(1) & vbTab)
Case "TEL;VOICE"
strOverig = strWaarde(1)
sbBuilder.Append(strWaarde(1) & vbCrLf)
Case "TEL;WORK;FAX"
strFaxWerk = strWaarde(1)
sbBuilder.Append(strWaarde(1) & vbTab)
Case "TEL;FAX"
strFaxThuis = strWaarde(1)
sbBuilder.Append(strWaarde(1) & vbCrLf)
Case "ADR;WORK;PREF:"
strAdres = strWaarde(1)
sbBuilder.Append(strWaarde(1) & vbCrLf)
Case "URL;HOME:"
strUrlThuis = strWaarde(1)
sbBuilder.Append(strWaarde(1) & vbTab)
Case "URL;WORK:"
strUrlWerk = strWaarde(1)
sbBuilder.Append(strWaarde(1) & vbCrLf)
Case "EMAIL;PREF;INTERNET:"
strMail = strWaarde(1)
sbBuilder.Append(strWaarde(1))
Case Else
sbBuilder.Append(strWaarde(1) & vbCrLf)
End Select
Loop
objReader.Close()
frmVCard.txtVCard.Text = sbBuilder.ToString
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Fout...")
Finally
objReader.Dispose()
sbBuilder = Nothing
End Try
End If
End Sub
I hope anyone can help me out.
Thanks already!