拖放打开文件

利用OLEDropMode属性和OLEDragDrop事件,可以轻松实现通过拖放文件到窗口来获得文件名,从而可以进一步做其他操作。

代码如下:

'用户昵称: 留下些什么
'个人简介: 一个会做软件的货代
'CSDN网址:https://blog.csdn.net/zezese
'电子邮箱:[email protected]

Option Explicit

Private Sub Form_Load()
    Me.OLEDropMode = DragModeConstants.vbAutomatic
End Sub

Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)

    Dim strFile
    
    For Each strFile In Data.Files
    
       Print strFile
        
    Next
    
End Sub

你可能感兴趣的:(VB实例源码,windows)