我尝试了以下代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Copy clipboard text twice
TextBox1.Text = Clipboard.GetText(TextDataFormat.Rtf)
TextBox2.Text = Clipboard.GetText(TextDataFormat.Rtf)
If TextBox1.Text = TextBox2.Text Then
'this is the output while copying from Notepad
OutputTextBox.Text = "True"
Else
'this is the output while copying from MS Word
OutputTextBox.Text = "False"
End If
End Sub
当我从 MS Word 复制文本时,两次获取富文本格式是不一样的。尽管文本已被复制一次并分配了两次。
我的代码有什么问题?