vb程序代码找出四个错误
2个回答
展开全部
Dim a() As Integer, i As Integer, p As String * 1, k As Integer
Dim st As String, q As String
st = Text1.Text
Do
i = i + 1
p = Mid(st, i, 1)
If p >= "0" And p <= "9" Then ''''2
q = q & p
Else
k = k + 1
ReDim Preserve a(k) ''''3
a(k) = Val(q)
q = "" ''''1
End If
Loop Until p = "#"
For i = 1 To UBound(a)
If prime(a(i)) Then List1.AddItem a(i)
Next
End Sub
Private Function prime(n As Integer) As Boolean
Dim i As Integer
For i = 2 To Sqr(n)
If n Mod i = 0 Then Exit Function ''''4
Next
prime = True
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询