第10講 添え字付き名前を持った箱(配列)
第6話 2つの添え字付き名前もった箱(2次元配列)の活用社員非ローカル版
自然配列・転置左右反転・上下反転・中心に対して点対称移動
社員非ローカル版
Private Sub CommandButton1_Click()
Dim a(9, 9) As Integer, i As Integer, j As Integer
For i = 0 To 9
For j = 0 To 9
a(i, j) = 10 * i + j + 1
Next
Next
For i = 0 To 9
For j = 0 To 9
Cells(6 + i, 1 + j) = a(i, j)
Next
Next
tentihyouji
sayuuhentenhyouji
jyougehantenhyouji
tentasyouidouhyouji
End Sub
Private Sub CommandButton2_Click()
Rows("6:200").Select
Selection.ClearContents
Cells(5, 2).Select
Selection.ClearContents
Cells(1, 1).Select
End Sub
Sub tentihyouji()
Dim a(9, 9) As Integer
Dim i As Integer, j As Integer
For i = 0 To 9
For j = 0 To 9
a(i, j) = Cells(6 + i, 1 + j)
Next
Next
Cells(16, 1) = "転置"
For i = 0 To 9
For j = 0 To 9
Cells(17 + i, 1 + j) = a(j, i)
Next
Next
End Sub
Sub sayuuhentenhyouji()
Dim a(9, 9) As Integer
Dim i As Integer, j As Integer
For i = 0 To 9
For j = 0 To 9
a(i, j) = Cells(6 + i, 1 + j)
Next
Next
Cells(28, 1) = "左右反転"
For i = 0 To 9
For j = 0 To 9
Cells(29 + i, 1 + j) = a(i, 9 - j)
Next
Next
End Sub
Sub jyougehantenhyouji()
Dim a(9, 9) As Integer
Dim i As Integer, j As Integer
For i = 0 To 9
For j = 0 To 9
a(i, j) = Cells(6 + i, 1 + j)
Next
Next
Cells(39, 1) = "上下反転"
For i = 0 To 9
For j = 0 To 9
Cells(40 + i, 1 + j) = a(9 - i, j)
Next
Next
End Sub
Sub tentasyouidouhyouji()
Dim a(9, 9) As Integer
Dim i As Integer, j As Integer
For i = 0 To 9
For j = 0 To 9
a(i, j) = Cells(6 + i, 1 + j)
Next
Next
Cells(50, 1) = "中心に対して点対称移動"
For i = 0 To 9
For j = 0 To 9
Cells(51 + i, 1 + j) = a(9 - i, 9 - j)
Next
Next
End Sub
次は、3つの添え字付き名前もった箱(3次元配列)の活用に挑戦して、
を実現します。
初心者のための世界で一番わかりやすいVisual C++入門基礎講座
初心者のための世界で一番わかりやすいVisual Basic入門基礎講座へ
vb講義へ
VB講義基礎へ
初心者のためのJava 入門 基礎から応用まで
数学研究室に戻る