VB5里面实现VB6的InstrRev()和Split()一样的替换函数

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 hnlzh 的 blog

private function split_vb5(byval sstr as string, spstr as string) as variant
dim starstr, lenstr, cur as integer
dim backstr() as string
starstr = instr(sstr, spstr)
cur = starstr + 1
lenstr = len(sstr)
redim backstr(0)
backstr(0) = left(sstr, starstr - 1)
for x = starstr + 1 to lenstr
    if mid(sstr, x, 1) = spstr then
        redim preserve backstr(ubound(backstr) + 1)
        backstr(ubound(backstr)) = mid(sstr, cur, x - cur)
        cur = x + 1
        debug.print backstr(ubound(backstr))
    end if
next
split_vb5 = backstr()
end function

'****************************** 

private function instrrev_vb5(byval start as integer, byval str1 as string, byval str2 as string)
str1 = revstr(str1)
str2 = revstr(str2)
start=len(str1)-start
instrrev_vb5 = len(str1) - instr(start, str1, str2)
end function

private function revstr(str as string) as string
dim x, lenstr as integer
lenstr = len(str)
for x = lenstr to 1 step -1
  revstr = revstr & mid(str, x, 1)
next
end function

本文关键:VB5 InstrRev()和Split()
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top