从vcf文件读取,以新形式写入文本框. [英] Read from vcf file, write to textboxes in a new form..

查看:77
本文介绍了从vcf文件读取,以新形式写入文本框.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还没有回答上一个问题,所以这是我的新问题:

这是我的VB.Net代码的一部分:

I haven''t an answer on my previous question yet, so here is my new question:

This is a part of my VB.Net Code:

'Importeert de gemaakte V-Card:
Private Sub btnImportVCard_Click(sender As System.Object, e As System.EventArgs) Handles btnImportVCard.Click

    'Voordat de V-Card kan worden geïmporteerd,
    'moet het bestand worden gelezen:
    Call Lezen()
End Sub

Private Sub MaakVCardToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles MaakVCardToolStripMenuItem.Click

    'Als er op de rechtermuisknop geklikt wordt dan..
    'komt er een menu met de volgende opties:
    If Windows.Forms.MouseButtons.Right Then

        'Een V-Card maken:
        Call VCard()
    End If
End Sub

Private Sub ImportVCardToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ImportVCardToolStripMenuItem.Click

    If Windows.Forms.MouseButtons.Right Then

        'Voordat de V-Card kan worden geïmporteerd,
        'moet het bestand worden gelezen:
        Call Lezen()
    End If
End Sub

'Verschillende menu opties.
'Maakt een V-Card d.m.v. het menu "Bestand":
Private Sub mnuMaakVCard_Click(sender As System.Object, e As System.EventArgs) Handles mnuMaakVCard.Click

    'Roept de private sub "selectRel" wanneer er geen relatie geselecteerd is:
    Call selectRel()
End Sub

'Importeert een V-Card d.m.v. het menu "Bestand":
Private Sub mnuImportVCard_Click(sender As System.Object, e As System.EventArgs) Handles mnuImportVCard.Click, rechtermuisMenuStrip.Click

    'Voordat de V-Card kan worden geïmporteerd,
    'moet het bestand worden gelezen:
    Call Lezen()
End Sub




与私人子Lezen我想从文本* .vcf文件中逐行读取文本.使用私有子导入器Importeren,我想在我的应用程序中将此内容写入文本框,并以新形式显示.如果有空行,那么我要转到下一行..etc等.

有人可以在正确的方向帮助我吗?




with the private sub Lezen i want to read the text line by line from a text *.vcf file. with the private sub Importeren i want to write this in my app to textboxes, showing in a new form. if there is an empty line, then i want to go to the next line..etc etc..

can someone help me in the good direction please?

推荐答案

我还是个初学者(...)我想将文本写入文本框在我的应用中.所以我的意思是..我已经保存了vcard文件(* .vcf),我想让用户选择以新格式打开该文件.

步骤:
1)设置TextBox1.MuliteLine = True
2)使用对话框 OpenFileDialog [
I''m still a beginner (...) i want to write the text to textboxes in my app. so what i mean is.. i have saved the vcard file(*.vcf) and i want to let user choos to open this file in a new form.

Steps:
1) set TextBox1.MuliteLine = True
2) Use Dialog OpenFileDialog[^] to let the user choose a file
3) Read lines:

Try
    ' Create an instance of StreamReader to read from a file.
    ' The using statement also closes the StreamReader.
    Using sr As New StreamReader("TestFile.txt")
        Dim line As String
        ' Read and display lines from the file until the end of
        ' the file is reached.
        Do
            line = sr.ReadLine()
            If Not (line Is Nothing) Then
                'here load new line to the TextBox
                 TextBox.Text = TextBox.Text & vbCrLf & line
            End If
        Loop Until line Is Nothing
    End Using
Catch e As Exception
    ' Let the user know what went wrong.
    Console.WriteLine("The file could not be read:")
    Console.WriteLine(e.Message)
End Try


如何:编写文本文件 [ vCards [
How to: Read text files[^]
How to: Write text files[^]

More about vCards[^].


这篇关于从vcf文件读取,以新形式写入文本框.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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