• 您的位置我爱Aspx >> VB.Net >> Visual Basci中的几个函数split(),ubound(),lbound(),instr(),mid().
  • Visual Basci中的几个函数split(),ubound(),lbound(),instr(),mid().

  • 作者:aspxer  来源:internet  日期:2007-5-20 13:52:06  关键字:
  • Visual Basci中的几个函数split(),ubound(),lbound(),instr(),mid().

    lit(包含子字符串和分隔符的字符串表达式 ,[分隔符],[要返回的子字符串数],[数字值表示判别子字符串时使用的比较方式]),[]部分为可选部分。该函数返回一个以零为下标的一维数组,它包含指定数目的子字符串。

    例:

    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

    我对这篇文章有话说?
  • 广告位招租,广告代号:content_468_15
  • 上一篇:VB应用之DOS程序窗口化
    下一篇:VB异步处理应用实例:磁盘文件全文搜索
  • 相关文章