vb 擷取檔案的副檔名
fn = "c:\test\123.doc" '檔案
MsgBox(System.IO.Path.GetExtension(fn)) '結果: ".doc"
''''''''''找"."在字串中的位置
fn1="123.doc"
'IndexOf由左到右"."
MsgBox(fn1.IndexOf(".")) '結果: 3
''''''''''''提取檔案,不加副檔名
ffname(fn1.Text)
Function ffname(ByVal nn As String) As String
Dim j As Integer
ffname = ""
j = 0
For i = nn.Length - 1 To 1 Step -1
If nn.Substring(i, 1) = "." Then Exit For Else j = i
Next
ffname = nn.Substring(0, j - 1)
End Function
沒有留言:
張貼留言