![]() |
#2
xiangyue05102016-04-22 09:02
|

Private Sub Command1_Click()
Static a(3, 4) As Integer '声明 数组
Static i As Integer
For j = 0 To 4 '取文本框控件数组接收到的数据存入二维数组中
a(i, j) = Val(Text1(j).Text) '一次提取一行
Next j
For j = 0 To 4
Text1(j) = "" '提取一行后清空文本框
Next j
If i = 2 Then '将要结束时提示可以打印
Command1.Caption = "打印"
End If
If i = 3 Then
Label1.Caption = "输入结束,开始处理数据" '数据都提取完毕后提示处理打印
Command1.Caption = "打印"
Print: Print: Print: Print
Print "您 输入的矩阵为:"
For k = 0 To 3 '以3行4列的矩阵方式输出数组元素
For j = 0 To 4
Print Tab(6 * j); a(k, j); '在窗体上有间隔的输出
Next j
Print
Next k
Exit Sub
Else
i = i + 1
Label1.Caption = "请您 输入第" & i + 1 & "行数据" '提示继续输入
Text1(0).SetFocus '光标重新定位
End If
End Sub
Private Sub Text1_GotFocus(Index As Integer) '当文本框控件数组中任何一个控件失去焦点时发生
n = Index
Text1(n).SelStart = 0
Text1(n).SelLength = Len(Text1(n).Text) '事件发生时文本框内的内容全部选中
End Sub
Static a(3, 4) As Integer '声明 数组
Static i As Integer
For j = 0 To 4 '取文本框控件数组接收到的数据存入二维数组中
a(i, j) = Val(Text1(j).Text) '一次提取一行
Next j
For j = 0 To 4
Text1(j) = "" '提取一行后清空文本框
Next j
If i = 2 Then '将要结束时提示可以打印
Command1.Caption = "打印"
End If
If i = 3 Then
Label1.Caption = "输入结束,开始处理数据" '数据都提取完毕后提示处理打印
Command1.Caption = "打印"
Print: Print: Print: Print
Print "您 输入的矩阵为:"
For k = 0 To 3 '以3行4列的矩阵方式输出数组元素
For j = 0 To 4
Print Tab(6 * j); a(k, j); '在窗体上有间隔的输出
Next j
Next k
Exit Sub
Else
i = i + 1
Label1.Caption = "请您 输入第" & i + 1 & "行数据" '提示继续输入
Text1(0).SetFocus '光标重新定位
End If
End Sub
Private Sub Text1_GotFocus(Index As Integer) '当文本框控件数组中任何一个控件失去焦点时发生
n = Index
Text1(n).SelStart = 0
Text1(n).SelLength = Len(Text1(n).Text) '事件发生时文本框内的内容全部选中
End Sub