一道visualbasic的题目!vb编程?

按图中要求写一份完整代码!谢谢大神... 按图中要求写一份完整代码!谢谢大神 展开
 我来答
旅初彤2B
2019-11-01 · TA获得超过2.6万个赞
知道大有可为答主
回答量:4.4万
采纳率:65%
帮助的人:5464万
展开全部
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
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式