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) –