1.改错题
Option Explicit Private Sub Command1_Click() Dim N As Integer, k As Integer For N = 20 To 180 k = N ^ 2 If sx(k) Then List1.AddItem N & "^2=" & k End If Next If List1.ListCount <> 0 Then List1.AddItem "无升序平方数" '错误点1修改为 List1.ListCount = 0 End Sub Private Function sx(ByVal N As Integer) As Boolean Dim num() As Integer, k As Integer, p As Integer Dim i As Integer Do p = N Mod 10 k = k + 1 ReDim Preserve num(k) num(k) = p N = N \ 10 Loop Until N<0 '错误点2,应修改为 N = 0
For i = 2 To UBound(num) If num(i) >num(i - 1) Then Exit Function '错误点3 修改为num(i) > num(i - 1) Next i sx = True End Function
|