Visual Basci中的几个函数split(),ubound(),lbound(),instr(),mi
来源:岁月联盟
时间:2005-06-23
例:
dim xx as variant
xx=split("hello world"," ")'将hello world 分隔为hello和world
text1.text= xx(0) '返回hello
text2.text=xx(1) '返回world
2.Ubound(数组名),该函数返回一个 Long 型数据,其值为指定的数组维可用的最大下标
Lbound(数组名),返回一个 Long 型数据,其值为指定数组维可用的最小下标。
例:
dim xx as variant
xx=split("hello world"," ")
text1.text=ubound(xx) '返回1
text2.text=lbound(xx) ‘返回0
3.Instr([start, ]string1, string2),该函数返回 Variant (Long),指定一字符串(string2)在另一字符串中(string1)最先出现的位置,如果没有找到返回0。[start,]为可选参数,表示搜索的开始位置。
例:
dim xx as string
xx="hello world"
text1.text=instr(xx,"o") '返回5
text2.text=instr(6,xx,"o") '返回8,从第6个字符开始查找
4.Mid(string, start[, length]),返回Variant (String),其中包含字符串(string)中指定长度[,length]的字符,start为开始位置。其中的[,length]为可选参数不指定长度,则返回start后的所有字符。
例:
dim xx as sting
xx="hello world"
text1.text=mid(xx,1,5)'返回hello
text2.text=mid(xx,1) '返回hello world
下一篇:vb.net和c#语法比较











