快捷搜索:  汽车  科技

access插入有运算公式的列:Access利用数组实现矩阵转换

access插入有运算公式的列:Access利用数组实现矩阵转换演 示:示例下载:http://www.accessoft.com/article-show.asp?id=20523

使用二维数组的一个例子,通过数组对行与列进行转换(即矩阵转换),从而实现对数据的分析,如下图:

access插入有运算公式的列:Access利用数组实现矩阵转换(1)

代码如下

Dim myArray(1 To 5 1 To 5) As Long
Dim intX As Integer
Dim intY As Integer
Private Sub Command5_Click()
Dim temp As Variant
For intX = 1 To 5
For intY = intX To 5
temp = myArray(intY intX)
myArray(intY intX) = myArray(intX intY)
myArray(intX intY) = temp
Next intY
Next intX
For intX = 1 To 5
For intY = 1 To 5
Me.Text6 = Me.Text6 & myArray(intX intY) & " "
Next intY
Me.Text6 = Me.Text6 & vbCrLf
Next intX
End Sub


Private Sub Command77_Click()
For intX = 1 To 5
For intY = 1 To 5
myArray(intX intY) = Int(Rnd * 100) 10
Next intY
Next intX
For intX = 1 To 5
For intY = 1 To 5
Me.Text3 = Me.Text3 & myArray(intX intY) & " "
Next intY
Me.Text3 = Me.Text3 & vbCrLf
Next intX
End Sub

演 示

access插入有运算公式的列:Access利用数组实现矩阵转换(2)

示例下载:http://www.accessoft.com/article-show.asp?id=20523

猜您喜欢: