(1/2)用VB程序编程:从键盘上输入10个整数,并放入一个一维数组中,然后将其前5个元素与后5个元素对换... 40
(1/2)用VB程序编程:从键盘上输入10个整数,并放入一个一维数组中,然后将其前5个元素与后5个元素对换,即第1个元素与第10个元素对换,第2...
(1/2)用VB程序编程:从键盘上输入10个整数,并放入一个一维数组中,然后将其前5个元素与后5个元素对换,即第1个元素与第10个元素对换,第2
展开
2个回答
展开全部
Private Sub Command1_Click()
Dim tmp As String, tmp1 As String, a() As String
Me.Cls
tmp = Text1.Text
If Not IsNumeric(tmp) Then GoTo OutErr
a = Split(tmp, ",")
If UBound(a) <> 9 Then MsgBox "请输入十个整数!", vbInformation, "提示": Exit Sub
For i = 0 To 4
tmp1 = a(i)
a(i) = a(9 - i)
a(9 - i) = tmp1
Next i
For i = 0 To 9
If Int(Val(a(i))) = Val(a(i)) Then
Me.Print a(i) & ",";
Else
Me.Print a(i) & "(不是整数)";
End If
Next i
Exit Sub
OutErr:
a = Split(tmp, ",")
For i = 0 To UBound(a)
If Not IsNumeric(a(i)) Then Me.Print vbCrLf & a(i) & "不是整数"
Next i
End Sub
Private Sub Text1_Change()
Dim a() As String
a = Split(Text1.Text, ",")
If a(UBound(a)) <> "" Then Label1.Caption = "共输入:" & UBound(a) + 1 & "个数"
End Sub
Dim tmp As String, tmp1 As String, a() As String
Me.Cls
tmp = Text1.Text
If Not IsNumeric(tmp) Then GoTo OutErr
a = Split(tmp, ",")
If UBound(a) <> 9 Then MsgBox "请输入十个整数!", vbInformation, "提示": Exit Sub
For i = 0 To 4
tmp1 = a(i)
a(i) = a(9 - i)
a(9 - i) = tmp1
Next i
For i = 0 To 9
If Int(Val(a(i))) = Val(a(i)) Then
Me.Print a(i) & ",";
Else
Me.Print a(i) & "(不是整数)";
End If
Next i
Exit Sub
OutErr:
a = Split(tmp, ",")
For i = 0 To UBound(a)
If Not IsNumeric(a(i)) Then Me.Print vbCrLf & a(i) & "不是整数"
Next i
End Sub
Private Sub Text1_Change()
Dim a() As String
a = Split(Text1.Text, ",")
If a(UBound(a)) <> "" Then Label1.Caption = "共输入:" & UBound(a) + 1 & "个数"
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Option Base 1
Private Sub Form_Click()
Dim a%(10)
For i = 1 To 10
a(i) = InputBox("输入第" & i & "个元素值:")
Print a(i);
Next i
Print
For i = 1 To 5
temp = a(i): a(i) = a(11 - i): a(11 - i) = temp
Next i
For i = 1 To 10
Print a(i);
Next i
End Sub
Private Sub Form_Click()
Dim a%(10)
For i = 1 To 10
a(i) = InputBox("输入第" & i & "个元素值:")
Print a(i);
Next i
For i = 1 To 5
temp = a(i): a(i) = a(11 - i): a(11 - i) = temp
Next i
For i = 1 To 10
Print a(i);
Next i
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询