1个回答
展开全部
Dim num(4), countNum, temp, tempA As Integer
Private Sub Command1_Click()
Dim a(), f As Boolean
countNum = 0
Text2.Text = ""
If Text1.Text = "" Then
MsgBox "请输入两个数字!"
Else
For i = 1 To Len(Text1.Text)
If IsNumeric(Mid(Text1.Text, i, 1)) Then
If f = False Then
f = True
ReDim a(0)
Else
ReDim Preserve a(UBound(a) + 1)
End If
a(UBound(a)) = Mid(Text1.Text, i, 1)
For j = i + 1 To Len(Text1.Text)
If IsNumeric(Mid(Text1.Text, j, 1)) Then
a(UBound(a)) = a(UBound(a)) & Mid(Text1.Text, j, 1)
i = i + 1
Else
Exit For
End If
Next j
End If
Next i
If f = True Then
For i = 0 To UBound(a)
countNum = countNum + 1
num(i) = a(i)
Next i
End If
If countNum <> 2 Then
MsgBox "你输入的数字不止2个!"
Else
temp = num(0)
num(0) = num(1)
num(1) = temp
End If
If countNum = 2 Then
For i = 0 To countNum - 1
If i <> countNum - 1 Then
Text2.Text = Text2.Text & num(i) & ","
Else
Text2.Text = Text2.Text & num(i)
End If
Next i
End If
End If
End Sub
Private Sub Command2_Click()
Dim a(), f As Boolean
countNum = 0
Text2.Text = ""
If Text1.Text = "" Then
MsgBox "请输入四个数字!"
Else
For i = 1 To Len(Text1.Text)
If IsNumeric(Mid(Text1.Text, i, 1)) Then
If f = False Then
f = True
ReDim a(0)
Else
ReDim Preserve a(UBound(a) + 1)
End If
a(UBound(a)) = Mid(Text1.Text, i, 1)
For j = i + 1 To Len(Text1.Text)
If IsNumeric(Mid(Text1.Text, j, 1)) Then
a(UBound(a)) = a(UBound(a)) & Mid(Text1.Text, j, 1)
i = i + 1
Else
Exit For
End If
Next j
End If
Next i
If f = True Then
For i = 0 To UBound(a)
countNum = countNum + 1
num(i) = a(i)
Next i
End If
If countNum <> 4 Then
MsgBox "你输入的数字不止4个!"
Else
temp = num(0)
num(0) = num(1)
num(1) = temp
tempA = num(2)
num(2) = num(3)
num(3) = tempA
End If
If countNum = 4 Then
For i = 0 To countNum - 1
If i <> countNum - 1 Then
Text2.Text = Text2.Text & num(i) & ","
Else
Text2.Text = Text2.Text & num(i)
End If
Next i
End If
End If
End Sub
Private Sub Command3_Click()
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Command4_Click()
Unload Form1
End Sub
Private Sub Command1_Click()
Dim a(), f As Boolean
countNum = 0
Text2.Text = ""
If Text1.Text = "" Then
MsgBox "请输入两个数字!"
Else
For i = 1 To Len(Text1.Text)
If IsNumeric(Mid(Text1.Text, i, 1)) Then
If f = False Then
f = True
ReDim a(0)
Else
ReDim Preserve a(UBound(a) + 1)
End If
a(UBound(a)) = Mid(Text1.Text, i, 1)
For j = i + 1 To Len(Text1.Text)
If IsNumeric(Mid(Text1.Text, j, 1)) Then
a(UBound(a)) = a(UBound(a)) & Mid(Text1.Text, j, 1)
i = i + 1
Else
Exit For
End If
Next j
End If
Next i
If f = True Then
For i = 0 To UBound(a)
countNum = countNum + 1
num(i) = a(i)
Next i
End If
If countNum <> 2 Then
MsgBox "你输入的数字不止2个!"
Else
temp = num(0)
num(0) = num(1)
num(1) = temp
End If
If countNum = 2 Then
For i = 0 To countNum - 1
If i <> countNum - 1 Then
Text2.Text = Text2.Text & num(i) & ","
Else
Text2.Text = Text2.Text & num(i)
End If
Next i
End If
End If
End Sub
Private Sub Command2_Click()
Dim a(), f As Boolean
countNum = 0
Text2.Text = ""
If Text1.Text = "" Then
MsgBox "请输入四个数字!"
Else
For i = 1 To Len(Text1.Text)
If IsNumeric(Mid(Text1.Text, i, 1)) Then
If f = False Then
f = True
ReDim a(0)
Else
ReDim Preserve a(UBound(a) + 1)
End If
a(UBound(a)) = Mid(Text1.Text, i, 1)
For j = i + 1 To Len(Text1.Text)
If IsNumeric(Mid(Text1.Text, j, 1)) Then
a(UBound(a)) = a(UBound(a)) & Mid(Text1.Text, j, 1)
i = i + 1
Else
Exit For
End If
Next j
End If
Next i
If f = True Then
For i = 0 To UBound(a)
countNum = countNum + 1
num(i) = a(i)
Next i
End If
If countNum <> 4 Then
MsgBox "你输入的数字不止4个!"
Else
temp = num(0)
num(0) = num(1)
num(1) = temp
tempA = num(2)
num(2) = num(3)
num(3) = tempA
End If
If countNum = 4 Then
For i = 0 To countNum - 1
If i <> countNum - 1 Then
Text2.Text = Text2.Text & num(i) & ","
Else
Text2.Text = Text2.Text & num(i)
End If
Next i
End If
End If
End Sub
Private Sub Command3_Click()
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Command4_Click()
Unload Form1
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询