交换数据界面,下面是交换数据代码:
Private Sub Command1_Click()
'交换第二列和第四列
Text1.Text = ""
Text2.Text = ""
Label1.Caption = ""
Dim AA(1 To 4, 1 To 4) As Integer, BB(1 To 4, 1 To 4) As Integer
Text1.Text = "交换前的数据" & vbCrLf
For I = 1 To 4
For J = 1 To 4
Randomize
AA(I, J) = Int(Rnd * 89 + 11)
BB(I, J) = AA(I, J)
Text1.Text = Text1.Text & AA(I, J) & Space(2) '显示交换前的数据
Next J
Text1.Text = Text1.Text & vbCrLf
Next I
For I = 1 To 4
For J = 1 To 4
If J = 2 Then
BB(I, J + 2) = AA(I, J) '将第二行数据存储到第四行
ElseIf J = 4 Then
BB(I, J - 2) = AA(I, J) '将第四行数据存储到第二行
End If
Next J
Next I
Text2.Text = "交换后的数据" & vbCrLf
For I = 1 To 4
For J = 1 To 4
Text2.Text = Text2.Text & BB(I, J) & Space(2) '显示交换后的数据
Next J
Text2.Text = Text2.Text & vbCrLf
Next I
End Sub
查找字符界面,下面是统计字符的代码:
Private Sub Command2_Click()
'统计结果
Label1.Caption = ""
Dim XX As String, YY As String, KK As Integer, DD() As String, KK1 As Integer
XX = Text1.Text
YY = Text2.Text
If Len(XX) <= 5 Then
MsgBox "文本框1输入的字符不能小于5个字符!"
Exit Sub
End If
If Len(YY) <> 1 Then
MsgBox "文本框2输入的字符必须是1个字符!"
Exit Sub
End If
KK = Len(XX)
ReDim DD(1 To KK)
KK1 = 0
For I = 1 To KK
DD(I) = Right(Left(XX, I), 1)
If Asc(DD(I)) = Asc(YY) Then KK1 = KK1 + 1
Next I
Label1.Caption = "文本框1中包含" & YY & "字符有" & KK1 & "个。"
End Sub
可以帮你完成,需要私信给我