我制作了一个程序,可以从网站上读取聊天消息并以特定格式显示在richtextbox中:
You're now chatting with a random stranger. Say hi!
You: Hi
Stranger: hi
Stranger has disconnected.
每次发送邮件时都会更新richtextbox。 我正在尝试创建一个包含Stranger发送的消息的字符串数组。因此每次Stranger发送新消息时,它都会被添加到数组中。这是我到目前为止所尝试的内容:
首先,我确保摆脱不必要的消息,例如系统消息:
Dim AvoidList() As String = {"Really?", " or turn on video", " My language English", " Find strangers with common interests (Enable)", "New", "Stop", "Esc", "Send", "Enter", "You're now chatting with a random stranger. Say hi!", "Stranger is typing...", "Connecting to server...", "Great chat? Save the log: Get a link • Select all • Or post log to: Facebook • Tumblr • Twitter • reddit"}
If Log.Text.Contains("You're now chatting with a random stranger. Say hi!") Or Log.Text.StartsWith("Stranger: ") Or Log.Text.StartsWith("You: ") Then
While (i < AvoidList.Length)
If Log.Text.Contains(AvoidList(i)) Then
Log.Text = Log.Text.Replace(AvoidList(i), "")
End If
i += 1
End While
然后我尝试将每一行放在我的字符串数组的一部分Messages
中,同时忽略空行,然后尝试将仅包含单词“Stranger:”的字符串存储在名为{{1的第二个字符串中但由于某种原因,第二个数组仍为空:
StrangerMessages
我在那里做错了什么?还有更好的方法来完成它吗?