RichTextBox控件DragDrop事件
这两天论坛故障,工作闲暇QQ时,有个网友问到RichTextBox控件DragDrop事件怎么统计拖拽文件个数,以及直接打开.TXT文件的问题Private Sub Form_Load()
RichTextBox1.OLEDropMode = 1 '将RichTextBox1设置为可接受拖拽
End Sub
Private Sub RichTextBox1_OLEDragDrop(Data As RichTextLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
Dim ss As String
For i = 1 To Data.Files.Count
ST = Right(Data.Files(i), 3)
If LCase(ST) Like "txt" Then
RichTextBox1.LoadFile Data.Files.Item(i)
ss = ss & RichTextBox1.Text
t = t + 1
End If
Next
RichTextBox1.Text = ss
MsgBox "你共拖拽了" & Data.Files.Count & "个文件,其中有" & t & "个TXT文本文件"
End Sub