Private Sub Command1_Click()
Dim a(1 To 20) As String
Dim ys As String, xs As String ‘s记录最大的新数
Dim k As Integer, h As Integer, n As Integer
Dim i As Integer, j As Integer
Dim F As Boolean
xs =“”
ys = Text1.Text
n = Len(ys)
k = Val( Text2.Text)
F = True
If ys =“”Or n > 20 Or k = 0 Or k > n Then
Label4.Caption = “输入的原数或保留位数不符,请重输!”
F = False
End If
For i = 1 To n
If a(i) < “0” Or a(i) > “9” Then
Label4.Caption =“输入的原数不是数字,请重输!”
Text1.Text = “”
F = False
End If
Next i
If F = True Then
h = 1
For i = 1 To n-k
For j = h To
If a(j) > a(h) Then h = j
Next j
h = h + 1
Next i
Text3.Text = xs
End If
End Sub