Hello,
I will try to give better explanation of my problem:
This is a V-Card file (vcf) all this info will be showing in my app.
There is only one line that is not working. I have tried a lot to get this right.
BEGIN:VCard
VERSION:2.1
N:De Jong
FN:Anne
TEL;WORK;VOICE:0512540540
TEL;WORK;VOICE:0512540540
TEL;HOME;VOICE:06-11299731
TEL;CELL;VOICE:06-11299731
TEL;VOICE:0512 540221
TEL;WORK;FAX:0512 540540
TEL;FAX:0512 540221
ADR;WORK;PREF:;;Sjoerd Veltmanstraat 15;Drachten;;9203 NJ
ENCODING=QUOTED-PRINTABLE:Sjoerd Veltmanstraat 15
URL;HOME:www.epixfotostudio.nl
URL;WORK:www.epixfotostudio.nl
EMAIL;PREF;INTERNET:odejong@epixfotostudio.nl
END:VCARD
ADR;WORK;PREF:;;Sjoerd Veltmanstraat 15;Drachten;;9203 NJ
This is the line I need to show.
This is my code:
Private Sub Importeren() _
Handles itemImporteerVCard.Click, mnuImportVCard.Click, _
btnImportVCard.Click
Dim strBestand As String = " "
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 intNummer As Integer = "720612"
Dim strSoort As String = "D"
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 strPostcode As String = " "
Dim strPlaats As String = " "
Dim strAdgegevens As String = strAdres & strPostcode & strPlaats
Dim strUrlThuis As String = " "
Dim strUrlWerk As String = " "
Dim strMail As String = " "
Dim strZoek As String = "testtest"
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(":")
strAdgegevens.Split(strAdres, strPostcode, strPlaats, ";")
Dim blnDubbel As Boolean
Select Case UCase(strWaarde(0))
Case "BEGIN", "VERSION", "END", _
"ENCODING=QUOTED-PRINTABLE"
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 blnDubbel = False Then
strTelWerk = strWaarde(1)
sbBuilder.Append(strWaarde(1) & vbTab)
blnDubbel = 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:"
strAdgegevens = 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
Dim strInsert As String
strInsert = "INSERT INTO Relaties (B22_relnr, B22_rel_soort, B22_naam, B22_voornaam_etc, " _
& "B22_adres, B22_postcode, B22_plaats, B22_telefoon1, B22_telefoon2, " _
& "B22_mobielnr, B22_faxnummer, B22_email, B22_www_adres, B22_zoeknaam) " _
& " VALUES (" & intNummer & ", '" & strSoort & "', '" & strNaam _
& "', '" & strVoornaam & "', '" & strAdres _
& "', '" & strPostcode & "', '" & strPlaats & "', '" & strTelWerk _
& "', '" & strTelThuis & "', '" & strMobiel & "', '" & strFaxWerk _
& "', '" & strMail & "', '" & strUrlWerk & "', '" & strZoek & "' )"
Dim ds_B22 As New OdbcCommand
ds_B22.CommandType = Data.CommandType.Text
ds_B22.CommandText = strInsert
ds_B22.Connection = cnn
ds_B22.ExecuteNonQuery()
If MsgBox _
("De V-Card is geïmporteerd", 0, "V-Card is geïmporteerd") Then
Exit Sub
End If
Catch ex As Exception
MsgBox _
(ex.Message, MsgBoxStyle.Exclamation, "Fout...")
Finally
objReader.Dispose()
sbBuilder = Nothing
End Try
End If
End Sub
It is a lot of code, I hope that you can understand what my purpose is.
My application can make a V-Card and now I'm trying to insert the V-Card.
The V-Card that I have inserted must send the info inside it.. into the right fields of my database.. That's the part where I'm busy with right now.
In the bold line i Need to Split the ":"and the ";"..but I don't know how to do it..
I hope that someone can help me with this problem.. I've only got a few days to complete my project.
[edit]Code block added - OriginalGriff[/edit]