求一段得到文件扩展名的vb代码
来源:百度知道 编辑:UC知道 时间:2024/05/21 13:15:51
比如说在c:\a c盘下的文件名字是a, 要一段代码 能得到a文件的扩展名。
谢谢大家
如果在a的扩展名未知的情况下?
谢谢大家
如果在a的扩展名未知的情况下?
按照你的要求修改了一下,方法有点非常规了
'添加窗体Form1,按钮Command1,然后添加如下代码:
Private Sub Command1_Click()
MsgBox fileType("c:\a")
End Sub
Private Function fileType(strFile As String) As String
Dim strTemp
Dim strTempInput As String
Dim strShortName As String
strShortName = Mid(strFile, InStrRev(strFile, "\") + 1)
Shell "cmd /c dir " & strFile & ".*>c:\temp.txt"
Open "c:\temp.txt" For Input As #1
Do While Not EOF(1)
Line Input #1