从键盘输10个整数存到一维数组中,求数组中最小元素的值和它的下标,结果输在窗体上。该怎么写VB程序啊?

2024年11月18日 03:19
有1个网友回答
网友(1):

Private Sub Command1_Click() Cls Dim a(1 To 10) As Integer Dim xb As Integer, min As Integer For i = 1 To UBound(a) a(i) = Val(InputBox("请你输入第" & i & "个数", , "1")) Print a(i); Next i Print xb = 1: min = a(1) For i = 2 To UBound(a) If a(i) < min Then min = a(i): xb = i Next i Print "下标值", "最小值" Print xb, min End Sub