function test(byval s as string) as boolean test=(ubound(split(s,")"))=ubound(split(s,"("))) exit function'调用 dim s as string s="a(bc)ed" msgbox test(s)
function test(byval s as string) as boolean test=(ubound(split(s,")"))=ubound(split(s,"("))) end function'调用 dim s as string s="a(bc)ed" msgbox test(s)
就我的理解给你答复一下: public function ifmatch(str as string) as boolean n=0; endpos=instr(str,"#") '求字符串的结束位置 for i=1 to endpos c=mid(str,i,1) if c="(" then n++; end if if c=")" then n--; end if next i if n=0 then ismatch=true else ismatch=false end if end function'函数的实现是通过一个变量n,依次读各个字符,若为"("则n++,若为")"则n--,最后若n为0说明是匹配的.
function test(byval s as string) as boolean test=(ubound(split(s,")"))=ubound(split(s,"("))) end function'调用 dim s as string s="a(bc)ed" msgbox test(s)
test=(ubound(split(s,")"))=ubound(split(s,"(")))
exit function'调用
dim s as string
s="a(bc)ed"
msgbox test(s)
function test(byval s as string) as boolean
test=(ubound(split(s,")"))=ubound(split(s,"(")))
end function'调用
dim s as string
s="a(bc)ed"
msgbox test(s)
public function ifmatch(str as string) as boolean
n=0;
endpos=instr(str,"#") '求字符串的结束位置
for i=1 to endpos
c=mid(str,i,1)
if c="(" then
n++;
end if
if c=")" then
n--;
end if
next i
if n=0 then
ismatch=true
else
ismatch=false
end if
end function'函数的实现是通过一个变量n,依次读各个字符,若为"("则n++,若为")"则n--,最后若n为0说明是匹配的.
可能是我没有描述清楚,我的意思是采用'inputbox("请输入字符串:")'方式获得的字符串。
然后,象c中类似的定义数组char ch[]="ajigljj",
if(ch[2]=='#')
return true;2、
能解释一下,代码吗?
刚开始学vb,有好多的不明白。。
eg. ubound ,split
function test(byval s as string) as boolean
test=(ubound(split(s,")"))=ubound(split(s,"(")))
end function'调用
dim s as string
s="a(bc)ed"
msgbox test(s)