0
我有一个自己编写的一个同事的通讯送入用工具发送电子邮件这样的后写入一个文本日志:拆分阵列和读取特定行
Count of emails to send: 10
Count of sent emails: 10
<German> Sender: [email protected] Header: New Newsletter 01/2017, file: C:\temp\raw_newsletter_htm_german.htm
1. (30.01.2017 10:28:45) ------ [email protected]
4. (30.01.2017 10:28:46) ------ [email protected]
5. (30.01.2017 10:28:47) ------ [email protected]
9. (30.01.2017 10:28:47) ------ [email protected]
10. (30.01.2017 10:28:47) ------ [email protected]
<English> Sender: [email protected] Header: New Newsletter 01/2017, file: C:\temp\raw_newsletter_htm_english.htm
2. (30.01.2017 10:28:46) ------ [email protected]
3. (30.01.2017 10:28:46) ------ [email protected]
6. (30.01.2017 10:28:47) ------ [email protected]
7. (30.01.2017 10:28:47) ------ [email protected]
8. (30.01.2017 10:28:47) ------ [email protected]
现在我的问题:如何我可以按语言拆分日志并将它们写入2个不同的文本框?我尝试了以下内容,它只检查行是否包含“------”,因为这些是我需要的唯一行。但我不知道,我怎么能用语言来分裂他们。
Private Sub readlog_Click(sender As Object, e As EventArgs) Handles readlog.Click
Dim text As String() = File.ReadAllLines("C:\temp\log_01_2017.txt")
TextBox1.Text = ""
Dim entries As String = ""
For Each line In text
If line.Contains("------") Then
entries += vbNewLine & line
End If
Next
TextBox1.Text = entries
End Sub
我想过像line.contains("<German>")
,则忽略第一行,因为它是发件人/头/文件中的行,并一直读到line.contains("<English>")
,然后用英文重新开始。但我没有真正的想法如何写这个代码。
在此先感谢
对我来说,这是行不通的,因为'destinationTextBox'仍然是'nothing'当'案例ln.Contains(“------” )'被调用。我怎样才能使destionationTextBox =从第一个案件的结果,然后在第二个案件中使用它? – neverlucky
也许我昨天出了点问题。 'destinationTextbox'不是'nothing',但每当我尝试通过添加'MsgBox(destinationTextbox.ToString())'来获取当前选择的国家时,它只是告诉我:'System.Windows.Forms.RichTextBox,Text: ',而不是上面的if-clause分配的值。我该如何解决这个问题? – neverlucky
MsgBox(destinationTextbox.ToString())只显示''name'属性'destinationTextBox'的默认属性。你应该使用MsgBox(destinationTextbox.Text) –