VB数组的定义教学内容.docVIP

  • 25
  • 0
  • 约2.17千字
  • 约 3页
  • 2020-09-08 发布于浙江
  • 举报
定义数组 Dim a(n这个n可以是常量、常量表达式如5*1 5*5 5/1 5+5 5-3等) as typeType是指类型可以是:Integer 这个n可以是常量、常量表达式 如5*1 5*5 5/1 5+5 5-3等 Type是指类型可以是: Integer String Long 等 A是一个type型的数组,这个数组共有n个元素,最小下标为0(也就是从0开始),最大下标为n-1。 注意n可以是常量、常量表达式,千万不能是变量。这个n的类型只能是数值型。 如下 Dim a(5) as integer //定义一个integer型的数组a,共有5个元素。 Dim s(5) as string //定义一个string型的数组s,共有5个元素。 Dim a(5+1) as integer //定义一个integer型的数组,共有6个元素。 Dim a(5*10) as integer //定义一个integer型的数组,共有50个(50*10)元素. 还可以这么定义: const ARRCOUNT=50 //定义一个常量(以后在程序中要是有碰到 ARRCOUNT就相当于碰到50) dim a(ARRCOUNT) as integer //定义一个integer型的数组,共有50个元素 dim a(ARRCOUNT+1) as integer //

文档评论(0)

1亿VIP精品文档

相关文档