访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容
function button_click() Dim Input as Integer Dim Total(100) as Integer, nCounter as Integer Input = 输入的文字转成数值 nCounter = 1 select case Input case -1 '找出Total阵列内最大与最小的值,并显示之 case Else Total(nCounter) = Input nCounter = nCounter +1 end select end function
Dim Input As Integer '输入值 Dim nCounter As Integer = 0 '计算输入次数用来增加暂存阵列大小 Dim Total(nCounter) As Integer '输入暂存阵列 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If IsNumeric(TextBox1.Text) Then '判断输入值是否为数字 Input = Int(TextBox1.Text) '输入值转成数值 TextBox1.Text = "" : TextBox3.Text = "" '清空tetbox1.tetbox3 If Input = -1 Then '输入值为-1就结束 Button1.Enabled = False '关闭输入按键 Label3.Text = "最大值:" & Total(UBound(Total)) Label4.Text = "最小值:" & Total(0) Else TextBox2.Text &= Input & vbNewLine ReDim Preserve Total(nCounter) '增加输入暂存阵列 Total(nCounter) = Input '输入值新增至输入暂存阵列中 nCounter = nCounter + 1 '增加阵列 End If Array.Sort(Total) For i As Integer = 0 To UBound(Total) TextBox3.Text &= Total(i) & vbNewLine 'textbox3显示排序后之数值 Next Else MsgBox("请输入数字") '输入值不为数字警告视窗 TextBox1.Text = "" '清空tetbox1 End If End Sub