概述'带
扩展名的
文件名 Private Sub Form_Load() Dim nopath As String nopath = TrimPath("C:\TXTFILES\JUSTFILE.TXT") MsgBox nopath End Sub Public Function TrimPath(sPath As String) As String Dim i As '带扩展名的文件名 Private Sub Form_Load() Dim nopath As String nopath = TrimPath("C:\TXTfileS\JUSTfile.TXT") MsgBox nopath End Sub Public Function TrimPath(sPath As String) As String Dim i As Integer,j As Integer i = InStrRev(sPath,"\") + 1 TrimPath = MID(sPath,i) End Function ---------------------------------------------------------------------------------------------------------- '不带扩展名的文件名 Private Sub Form_Load() Dim nopath As String nopath$ = TrimPath("C:\TXTfileS\JUSTfile.TXT") MsgBox nopath End Sub Public Function TrimPath(sPath As String) As String Dim i As Integer,"\") + 1 j = InStrRev(sPath,".") - 1 TrimPath = MID(sPath,i,j - i) End Function ---------------------------------------------------------------------------------------------------------- '只返回扩展名 Private Sub Form_Load() Dim nopath As String nopath = TrimPath("C:\TXTfileS\JUSTfile.TXT") MsgBox nopath End Sub Public Function TrimPath(sPath As String) As String Dim i As Integer i = InStrRev(sPath,".")+1 TrimPath = MID(sPath,i) End Function ---------------------------------------------------------------------------------------------------------- '托放 *** 作得到文件扩展名 Private Sub Form_Load() Me.olEDropMode = 1 End Sub Private Sub Form_olEDragDrop(Data As DataObject,Effect As Long,button As Integer,Shift As Integer,X As Single,Y As Single) Print TrimPath(Data.files(1)) End Sub Public Function TrimPath(sPath As String) As String Dim i As Integer i = InStrRev(sPath,".") + 1 If i = 1 Then TrimPath = "这可能是文件夹或没有扩展名的文件" Exit Function End If TrimPath = MID(sPath,i) End Function 总结
以上是内存溢出为你收集整理的不用api,vb自带函数得到文件名或扩展名全部内容,希望文章能够帮你解决不用api,vb自带函数得到文件名或扩展名所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
评论列表(0条)