Split现在正在进行下一步 [英] Split is working now to the next step

查看:84
本文介绍了Split现在正在进行下一步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



split方法正在工作..我已经制作了字符串,但似乎我不需要它们..
我的下一个步骤是在vcard文件中显示文本->进入我的应用,显示为自制vcard

[edit]添加了代码块-OriginalGriff [/edit]



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]

推荐答案

OdeJong,我不知道你想要什么,我只能猜测...

在您以前的帖子中,我给了您解决方案.看看修改后的代码:
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:
        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



可能您想将字段的每个值(NFNTEL等)读取到不同的文本框中.在上面的示例中,我将展示如何在多行文本框中显示vCard的内容.

希望对您有所帮助.



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.


这篇关于Split现在正在进行下一步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆