Module Module1
成都創(chuàng)新互聯(lián)主要從事網(wǎng)站設(shè)計、成都網(wǎng)站制作、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)雞西,10多年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):028-86922220
Sub Main()
Dim i, k As Integer
Dim a(,) As Integer = {{1, 2}, {2, 4}, {3, 4}}
For i = 0 To 2
For k = 0 To 1
Console.Write("a({0},{1})={2} ", i, k, a(i, k))
Next
Console.WriteLine()
Next
Console.Read()
End Sub
End Module
數(shù)組好像沒有快速賦值吧,或者你再把問題再清楚一點。
語句執(zhí)行時間倒是可以做到。在語句前
Dim oldTime As Date = Now
在過程語句后加
Dim newTime As Date = Now
Dim differenceInSeconds As Long = DateDiff(DateInterval.Second, oldTime, newTime)
textbox1.text= "共用了:" differenceInSeconds "秒!"
Dim abc(2) As Integer
abc = {0, 1, 2}
'或者
Dim abcd() As Integer
ReDim abcd(9)
For i As Integer = 0 To abcd.Length - 1
abcd(i) = i
Next
也可聲明為字符串?dāng)?shù)組
vb賦值給數(shù)組,有以下幾種方式:
第一種方式:
Private Sub Command1_Click()
Dim a(10) As Integer '定義數(shù)組a,下標(biāo)最大值為10
For i = 0 To 10
a(i) = i'這里可以直接給數(shù)組賦值了
Print "a(" i ")的值" a(i) '打印數(shù)組
Next
End Sub
第二種方式:
Private Sub Command1_Click()
Dim a() As Integer '定義數(shù)組a,這里未設(shè)置下標(biāo)
For i = 0 To 10
ReDim Preserve a(i)'ReDim 語句改變數(shù)組的元素以及維數(shù)的數(shù)目
a(i) = i'這里可以直接給數(shù)組賦值了
Print "a(" i ")的值" a(i)
Next
End Sub
第三種方式:
Private Sub Command1_Click()
a = Array(1, 5, 2, 43, 222)
MsgBox "a(0)原來的值是:" a(0)
a(0) = 100
MsgBox "a(0)賦值后的值是:" a(0)
End Sub
Dim n, i, j As Integer
'這里你用的是默認(rèn)的值,所以N是0,這樣,下面的那句話就成了
Dim a(n - 1, n - 1) As Long
'Dim a(0-1,0-1) As Long 也就是 Dim a(-1,-1) As Long
以后調(diào)用的時候肯定會出錯
Dim x(8, 8)
Dim a As Integer
Dim b As Integer
b = 0
For i = 0 To 8
For j = 0 To 8
If b = 3 Then
b = 1
a = a + 1
Else
b = b + 1
End If
x(i, j) = aNext
Next