Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Dim strBestand As String = ("c:\Test.vcf") 'String.Empty
        Dim strRegel As String = Nothing
        Dim strCols() As String = Nothing
        Dim objReader As System.IO.StreamReader = 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 = ""



        'Bevestiging voor het importeren:
        If MsgBox("Wilt u een v-Card Importeren?", 36, "Bevestiging voor het importeren") = MsgBoxResult.Yes Then
            Try
                'Eigenschappen voor het openen van de V-Card:
                ofdImport.Filter = "V-Cards (*.vcf)|*.vcf"
                ofdImport.FileName = "*.vcf"
                ofdImport.Title = "V-Card importeren"

                If ofdImport.ShowDialog = System.Windows.Forms.DialogResult.OK Then
                    'strBestand = ("C:\Test.vcf")
                    objReader = New System.IO.StreamReader(strBestand)
                    frmVCard.Show()
                End If

                Do While objReader.Peek >= 1
                    strRegel = objReader.ReadLine()
                    strCols = strRegel.Split(":")
                    'If StartPosition >= 1 Then

                    If InStr(strRegel, "N:") Then
                        'strNaam =
                        frmVCard.txtVCard.Text = frmVCard.txtVCard.Text & strCols(1) & vbCrLf

                    ElseIf InStr(strRegel, "FN:") Then
                        frmVCard.txtVCard.Text = frmVCard.txtVCard.Text & strCols(1) & vbCrLf
                        '    strVoornaam = strCols(1) & vbCrLf

                    ElseIf InStr(strRegel, "TEL;WORK;VOICE:") Then
                        frmVCard.txtVCard.Text = frmVCard.txtVCard.Text & strCols(1) & vbCrLf
                        '    strTelWerk = strCols(1) & vbCrLf

                    End If

                Loop
                objReader.Close()

            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Fout...")

            Finally
                objReader.Dispose()

            End Try
        End If


The split method is working.. i have make strings but it seems that i Dont need them..
My next stap is to display the text within a vcard file --> into my app, showing as a self made vcard

[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 31-May-12 22:29pm
v6
Comments
RDBurmon 30-May-12 7:46am    
Post your actual text in C:\Test.vcf
OdeJong 30-May-12 7:56am    
Sorry I don't know what u mean. Can u give me an example?
OriginalGriff 1-Jun-12 3:52am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.

1 solution

OdeJong, i don't know what you want, i can only guess...

In your previous post i gave you the solution. Take a look at modified code:
VB
        Dim sFileName As String = String.Empty, sLine As String = String.Empty, sCols() As String = Nothing
        Dim objReader As System.IO.StreamReader = Nothing, sb As System.Text.StringBuilder = Nothing

        Try
            sFileName = "F:\myCard.vcf"
            sb = New System.Text.StringBuilder

            Me.Text = sFileName
            objReader = New System.IO.StreamReader(sFileName)
            Do While objReader.Peek >= 1
                sLine = objReader.ReadLine()
                sCols = sLine.Split(":") 'split text by :
                Select Case UCase(sCols(0))
                    Case "BEGIN", "END", "VERSION"
                        GoTo SkipNext 'do not add "VCARD" and "VersionNo.", read next line
                    Case "N"
                        sb.Append("Name = " & sCols(1))
                    Case "FN"
                        sb.Append("FName = " & sCols(1))
                    Case Else
                        sb.Append(sCols(1))
                End Select
                sb.Append(sCols(1) & vbCrLf)
SkipNext:
            Loop
            objReader.Close()
            Me.TextBox1.Text = sb.ToString

        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error...")
        Finally
            objReader.Dispose()
            sb = Nothing

        End Try


Probably, you want to read each value of field (N, FN, TEL and others) into different textboxes. In the above example, i'll show how to display the content of vCard in the multiline textbox.

I hope, it helps.
 
Share this answer
 
Comments
OdeJong 1-Jun-12 5:33am    
Thanks for your answer! this is the best solution so far.. I'm now @ the next step so I think that I can work a little more with my project now. Thanks! 5!
Maciej Los 1-Jun-12 6:08am    
You're welcome ;)
VJ Reddy 5-Jun-12 19:57pm    
Good answer. 5!
Maciej Los 6-Jun-12 9:03am    
Thank you, VJ ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900