这是我的代码的示例输出,一个简单的聊天程序:
John says: Hello there!
Marsha says: Hi there!
John says: First sentence.
Marsha says: Second Sentence.
在文本框控件中,如上所示。但是,在用于存储对话的字典中,它将是这样的:
John says: First sentence.
Marsha says: Hi there!
John says: First sentence.
Marsha says: Second sentence.
我已经多次检查了我的代码......对于我的生活,我无法确切地说出我可能在哪里出错。
我已将问题追溯到 sendmsgbutton 方法,如下所示:
Private Sub sendMsgButton_Click(sender As System.Object, e As System.EventArgs) Handles sendMsgButton.Click
If rtnConnectStatus(t) = False Then
RaiseEvent statusCheck("Not Connected" + ControlChars.CrLf)
Else
Dim completeMsg As String
msg.Name = nameText.Text
msg.Message = msgTxt.Text
completeMsg = msg.ToString
msgRecorded.Text &= completeMsg
RaiseEvent statusCheck("Message Sent." + ControlChars.CrLf)
msgList.Add(msgListIndex, msg)
'RaiseEvent debugBox(msg, msgListIndex)
msgListIndex += 1
RaiseEvent DataSend(completeMsg)
msgTxt.Clear()
End If
End Sub
这是 msgList 继承自的字典类:
Public Class MsgDictionary
Inherits DictionaryBase
Public Property Item(ByVal key As Integer) As MsgObj
Get
Return CType(Dictionary(key), MsgObj)
End Get
Set(ByVal m As MsgObj)
Dictionary(key) = m
End Set
End Property
Public Sub Add(ByVal index As Integer, ByVal m As MsgObj)
Dictionary.Add(index, m)
End Sub
End Class
我的下一个测试是查看它是否只是消息值或者名称值是否也受此影响。
在此先感谢您提供任何帮助/建议。
编辑:为了澄清,每个字典条目的名称和字符串部分作为单个字典对象的属性。