当前位置:编程学习 > VB >>

vb编程 找出所有3-5位数中的升序数

所谓升序数就是个位大于十位,十位大于百位的三位数 如 123

这段程序改改错,可以实现么?

Private Sub Command1_Click()
Dim n As Integer, st, fi, i As Long
n = Val(Text1.Text)
st = 10 ^ (n - 1): fi = 10 ^ n - 1
For i = st To fi
If increase(i) Then List1.AddItem i
Next i
End Sub

Private Function increase(n As Long) As Boolean
Dim k As Integer, a() As Integer, i As Integer
k = Len(CStr(n))
ReDim a(k)
For i = k To 1
a(i) = n Mod 10
n = n \ 10
Next i
For i = 1 To k - 1
If a(i) >= a(i + 1) Then Exit For
Next i
increase = True
End Function

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,