Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long Private Sub Command1_Click() Clipboard.Clear RichTextBox1.Text = "abc中华人民共和国" Clipboard.SetData Picture1.Picture RichTextBox1.SelStart = Len(RichTextBox1.Text) RichTextBox1.SelText = vbCrLf RichTextBox1.SetFocus SendKeys Space(lstrlen(RichTextBox1.Text) - Len(RichTextBox1.Text)) SendKeys "^v", True End Sub
Option ExplicitPrivate Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Const WM_PASTE As Long = &H302Function Paste2RTB(rtb As RichTextBox) As Boolean Dim lLen As Long, lExtra As Long With rtb lLen = Len(.Text) lExtra = LenB(StrConv(.Text, vbFromUnicode)) - lLen .SelStart = lLen If lExtra > 0 Then .SelText = Space$(lExtra) End If SendMessage .hwnd, WM_PASTE, 0, ByVal 0 If lExtra > 0 Then .SelStart = Len(.Text) - lExtra .SelLength = lExtra .SelText = "" End If End With End FunctionPrivate Sub Command1_Click() Paste2RTB RichTextBox1 End SubPrivate Sub Form_Load() Clipboard.Clear RichTextBox1.Text = "abc中华人民共和国" Clipboard.SetData Picture1.Picture End Sub
Private Sub Command1_Click()
Clipboard.Clear
RichTextBox1.Text = "abc中华人民共和国"
Clipboard.SetData Picture1.Picture
RichTextBox1.SelStart = Len(RichTextBox1.Text)
RichTextBox1.SelText = vbCrLf
RichTextBox1.SetFocus
SendKeys Space(lstrlen(RichTextBox1.Text) - Len(RichTextBox1.Text))
SendKeys "^v", True
End Sub
SendKeys "^End"
SendKeys "^End"
SendKeys "^End"
SendKeys "^End"
SendKeys "^End"
SendKeys "^End"
SendKeys "^End"
SendKeys "^End"
'这时肯定是文章末尾了
Private Const WM_PASTE As Long = &H302Function Paste2RTB(rtb As RichTextBox) As Boolean
Dim lLen As Long, lExtra As Long
With rtb
lLen = Len(.Text)
lExtra = LenB(StrConv(.Text, vbFromUnicode)) - lLen
.SelStart = lLen
If lExtra > 0 Then
.SelText = Space$(lExtra)
End If
SendMessage .hwnd, WM_PASTE, 0, ByVal 0
If lExtra > 0 Then
.SelStart = Len(.Text) - lExtra
.SelLength = lExtra
.SelText = ""
End If
End With
End FunctionPrivate Sub Command1_Click()
Paste2RTB RichTextBox1
End SubPrivate Sub Form_Load()
Clipboard.Clear
RichTextBox1.Text = "abc中华人民共和国"
Clipboard.SetData Picture1.Picture
End Sub