當前位置:編程學習大全網 - 電腦編程 - vb如何為數組賦初值

vb如何為數組賦初值

2種方法

1. 直接賦值,此法只適合和小數組

Dim myArray() as Integer ={1,2,3,4,5}

或Dim myArray(5)as integer

myArray(0)=1

myArray(1)=2

myArray(2)=3

myArray(3)=3

myArray(4)=5

myArray(5)=6

2.最常用的for next循環賦值

Dim myArray()as integer

For intCount as Integer= 0 to 5

myArray(intCount)=妳要賦值的東西

Next

如果妳要每個都不同那就這樣:

Dim myArray()as integer

Dim FuZhi as integer

For Fuzhi as 0 to 5

For intCount as Integer= 0 to 5

myArray(intCount)=fuzhi

Next intCount

Next fuzhi

  • 上一篇:用海龜編輯器華氏度和攝氏度的換算
  • 下一篇:兩件式內螺紋球閥的主要零件材料
  • copyright 2024編程學習大全網