更改文件的扩展名 [英] Change extention of file
本文介绍了更改文件的扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好我存在扩展文件的问题。例如:
Dim s,s1 As String
s =" Test.doc"
i想得到s的值在s1中为Test.txt。例如:
s1 =" Test.txt
所以,我怎么能以简单的方式获得该解决方案?是否有任何功能可以通过任何特殊字符(例如(。)dot)来填充字符串,或仅更改扩展名? thx advance
Hi all I have a problem with extention of file. such as:
Dim s, s1 As String
s = "Test.doc"
i want get the value of s is in s1 as "Test.txt" such as :
s1 = "Test.txt"
so, how i can get that solution in easy way pls? Is there any bulit in function to saperate a string by any special char such as (.) dot, or change the extention only? thx advance
推荐答案
您可以使用instr函数找到。,然后使用左侧函数返回名称部分(减去扩展名) 。
Dim s,s1
s =" test.xxx"
s1 = left(s& ;"。",instr(s&"。","。") - 1)
''s1 =" test"此时
s1 = s1& " .txt"
''s1 =" test.txt"在这里。
希望有帮助....
You can use the instr function to locate the ".", and then the left function to return just the name part (less the extention).
Dim s, s1
s = "test.xxx"
s1 = left(s & ".",instr(s & ".",".")-1)
'' s1 = "test" at this point
s1 = s1 & ".txt"
'' s1 = "test.txt" here.
Hope that helps....
非常感谢您的解决方案,我的问题实际上是字符串拆分,例如
dim s,s1(100)as string
s =''x1.txt; x2.txt; x3.txt; x4.txt"
这里的分号是字符串中每个文件的分离,我想从这个字符串中分割文件名。
输出:s1(0)= x1.txt
s1(1)= x2.txt ......
它的意思是我如何搜索字符串的caharcter?如果蚂蚁想法将获得帮助,rthx再次
Thanks very much for ur solution, my problem actually with string split such as
dim s ,s1(100) as string
s=''x1.txt;x2.txt;x3.txt;x4.txt"
Here semicolon is saperation of each file in a string, I want to split the file name from this string.
output: s1(0)=x1.txt
s1(1)=x2.txt ......
Its mean how i can search the caharcter of a string? If ant idea which will be graet help, rthx again
您可以使用instr函数来找到。,并且然后左边的函数只返回名称部分(减去扩展名)。
Dim s,s1
s =" test.xxx" ;
s1 = left(s&"。",instr(s&"。","。") - 1)
's1 =测试此时
s1 = s1& " .txt"
''s1 =" test.txt"这里。
希望有帮助....
You can use the instr function to locate the ".", and then the left function to return just the name part (less the extention).
Dim s, s1
s = "test.xxx"
s1 = left(s & ".",instr(s & ".",".")-1)
'' s1 = "test" at this point
s1 = s1 & ".txt"
'' s1 = "test.txt" here.
Hope that helps....
如果文件名包含 dot (例如MyFile.YourFile.doc)?
Rey Sean
How about if the filename contains dot (e.g. MyFile.YourFile.doc)?
Rey Sean
这篇关于更改文件的扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文