江苏省高校计算机等级考试命题研究院 江苏省高校计算机等级考试辅导
江苏二级vb2010春上机试题

改错题:

Option Explicit
Private Sub Command1_Click()
Dim N As Integer, K As Long, St As String
For N = 500 To 800
    K = N ^ 2
    If Validate(N) And Validate(K) Then
        St = N & "^2=" & K
        List1.AddItem St
    End If
Next N
End Sub
Private Function Validate(ByVal N As Long) As Boolean '错误点1byval
Dim P As String, i As Integer, a() As Integer, j As Integer
P = CStr(N) '错误点2str(n)
ReDim a(Len(P))
For i = 1 To Len(P)
    a(i) = Mid(P, i, 1)
Next i
For i = 1 To UBound(a) - 1
    For j = i + 1 To UBound(a)
        If a(i) = a(j) Then Exit Function     '错误点3Exit For
    Next
Next
Validate = True
End Function