不用api,vb自带函数得到文件名或扩展名

不用api,vb自带函数得到文件名或扩展名,第1张

概述'带扩展名文件名 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自带函数得到文件名或扩展名所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1290291.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存