刚刚学VB 向高手求救 将数组元素倒序,输出 10
展开全部
'给个万能的,想输入多少数据都可以,程序以调试可用
Dim i As Integer, n As Integer
If TextBox0.Text = "" Then
MsgBox("请输入您想输入数字的个数")
Exit Sub
End If
n = CInt(TextBox0.Text)
Dim ar(n) As Integer
For i = 0 To n - 1
MsgBox("请输入第" & Str(i + 1) & "个数字")
ar(i) = Val(InputBox("请输入")) '将输入的数据转换为数值型并赋值给数组
Next
Dim str1 As String, str2 As String
For i = 0 To n - 1
If str1 = "" Then
str1 = ar(i)
Else
str1 = str1 & " " & ar(i)
End If
Next
For i = 0 To n - 1
If str2 = "" Then
str2 = ar(n - 1 - i)
Else
str2 = str2 & " " & ar(n - 1 - i)
End If
Next
TextBox1.Text = str1
TextBox2.Text = str2
程序已调试,有问题再联系....
Dim i As Integer, n As Integer
If TextBox0.Text = "" Then
MsgBox("请输入您想输入数字的个数")
Exit Sub
End If
n = CInt(TextBox0.Text)
Dim ar(n) As Integer
For i = 0 To n - 1
MsgBox("请输入第" & Str(i + 1) & "个数字")
ar(i) = Val(InputBox("请输入")) '将输入的数据转换为数值型并赋值给数组
Next
Dim str1 As String, str2 As String
For i = 0 To n - 1
If str1 = "" Then
str1 = ar(i)
Else
str1 = str1 & " " & ar(i)
End If
Next
For i = 0 To n - 1
If str2 = "" Then
str2 = ar(n - 1 - i)
Else
str2 = str2 & " " & ar(n - 1 - i)
End If
Next
TextBox1.Text = str1
TextBox2.Text = str2
程序已调试,有问题再联系....
展开全部
数组编号a1-a10
令a(intenge)=a1
a1=a10
a10=a
就可以了
楼上的好快= =
令a(intenge)=a1
a1=a10
a10=a
就可以了
楼上的好快= =
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim a(1 To 10)
Private Sub Command1_Click()
For i = 1 To 10
a(i) = Val(InputBox(""))
Next i
Dim a(1 To 10)
Private Sub Command1_Click()
For i = 1 To 10
a(i) = Val(InputBox(""))
Next i
For i = 1 To 5
k = a(i)
a(i) = a(11 - i)
a(11 - i) = k
next i
for i = 1 to 10
print a(i);
next i
试试
Private Sub Command1_Click()
For i = 1 To 10
a(i) = Val(InputBox(""))
Next i
Dim a(1 To 10)
Private Sub Command1_Click()
For i = 1 To 10
a(i) = Val(InputBox(""))
Next i
For i = 1 To 5
k = a(i)
a(i) = a(11 - i)
a(11 - i) = k
next i
for i = 1 to 10
print a(i);
next i
试试
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
答案如下:
Option Base 1
Private Sub cmdInput_Click()
Dim data(1 To 10) As Integer
Dim lint_Index As Integer
Dim lstr_Value As String
'Input 10 numbers
For lint_Index = 1 To 10
lstr_Value = InputBox("Please input a valid number:", "Message")
If IsNumeric(lstr_Value) Then
data(lint_Index) = Val(lstr_Value)
End If
Next lint_Index
Output data
End Sub
'output these 10 numbers from 10 to 1
Private Sub Output(ByRef data() As Integer)
Dim lint_Index As Integer
For lint_Index = 10 To 1 Step -1
Print data(lint_Index)
Next
End Sub
Option Base 1
Private Sub cmdInput_Click()
Dim data(1 To 10) As Integer
Dim lint_Index As Integer
Dim lstr_Value As String
'Input 10 numbers
For lint_Index = 1 To 10
lstr_Value = InputBox("Please input a valid number:", "Message")
If IsNumeric(lstr_Value) Then
data(lint_Index) = Val(lstr_Value)
End If
Next lint_Index
Output data
End Sub
'output these 10 numbers from 10 to 1
Private Sub Output(ByRef data() As Integer)
Dim lint_Index As Integer
For lint_Index = 10 To 1 Step -1
Print data(lint_Index)
Next
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询