<>下面是fan0217老师写的字符串截取函数,有些地方需要改动,请高手赐教!!!<br>'===============================================================================<br>'-函数名称: MySplit<br>'-功能描述: 拆分字符串,获得指定格式<br>'-输入参数说明: 参数1:strMyStr As String 要拆分的字符串<br>'-返回参数说明: <FONT color=#ff0000>拆分:质检20060322-01-15-012-2</FONT> <FONT color=#ff0000>将获得:质检2006012<br></FONT>'-使用语法示例: MsgBox MySplit("质检20060322-01-15-012-2")<br>'-参考:<br>'-使用注意:<br>'-兼容性: 97,2000,XP,2003<br>'-作者: fan0217 <a href="mailto:fan0217@163.com" target="_blank" ><FONT color=#000000>fan0217@163.com</FONT></A><br>'-更新日期: 2006-04-10<br>'===============================================================================<br>Function MySplit(strMyStr As String) As String<br>Dim strTemp As String <br>
<>strTemp = Split(strMyStr, "-", -1)(0)<br>MySplit = Left(strTemp, Len(strTemp) - 4) <br>
<>MySplit = MySplit & Split(strMyStr, "-", -1)(3) <br>
<P>
<P>End Function<br></P>
<P><FONT color=#ff0000>问题:</FONT>我将上面标有红色记号的字改成:分析: <a href="http://876kjfs.sks.163.com/23421.html" target="_blank" >http://876kjfs.sks.163.com/23421.html</A> 和<a href="http://asdf-ss.sks.163.com/65768.html" target="_blank" >http://asdf-ss.sks.163.com/65768.html</A> 将获得:<U><FONT color=#0000ff>876kjfs.sks.163.com</FONT></U>和<U><FONT color=#0000ff>asdf-ss.sks.163.com <br></FONT></U>说得通俗点:就是要截取前面的"//"符号和后面的"/"符号中间的网站地址字符串<br><br>下面的代码:<br>'===============================================================================<br>Function MySplit(strMyStr As String) As String<br>Dim strTemp As String </P>
<P>
<P>strTemp = Split(strMyStr, "-", -1)(0) <FONT color=#ff0000>[这句该怎样改动?]<br></FONT>MySplit = Left(strTemp, Len(strTemp) - 4) <FONT color=#ff0000>[这句该怎样改动?]</FONT></P>
<P>
<P>MySplit = MySplit & Split(strMyStr, "-", -1)(3) <FONT color=#ff0000>[这句该怎样改动?]</FONT></P>
<P>End Function<br><br></P><FONT color=#ff0000 size=4></FONT>
<P align=center><FONT color=#ff0000 size=4>(问题已解决)</FONT></P>
[此贴子已经被作者于2007-7-29 4:04:06编辑过]
|