是语句逻辑错误,
If keyascii <> 13 Then
If keyascii < 48 Or keyascii > 57 Then
keyascii = 0
End If
Else
end if
上面这个判断已经将所以的键值都包含了,除了回车,那按那个键可以进入else下的语句。将If keyascii <> 13 Then 改成If keyascii = 13 Then,也不行。
还有 Text1Text = Int(Rnd 100)
Rnd函数没有初始化,要加Randomize
第一处:
'found' '请不要删除该行'
For j = i+1 To n
第二处:
'found' '请不要删除该行'
If i mod 10 = 0 Then Print
出现这个错误,是因为你的代码设置了Option Explicit,这就要求所有变量必须定义后才能使用。另外,题目要求IsPrime为函数,且返回值为布尔型,这点提问者以及其他的回答者都没有注意到!
Private Sub Command1_Click()Dim n As Long
n = Val(Text1Text)
Picture1Print n; IIf(IsPrime(n), "★", "")
End Sub
Private Function IsPrime(ByVal n As Long) As Boolean
Dim i As Long
For i = 2 To Sqr(n)
If n Mod i = 0 Then Exit Function
Next i
IsPrime = True
End Sub
Option Explicit
Option Base 1
Dim a() As Integer, n As Integer
Private Sub Command1_Click()
Dim I As Integer
n = InputBox("请输入数组个数", 10)
ReDim a(n)
For I = 1 To n
a(I) = Int(Rnd 100) + 1
Text1 = Text1 & Str(a(I))
Next I
Call Lookup(a)
For I = 1 To n - 1
Text2 = Text2 & Str(a(I))
Next I
End Sub
Private Sub Lookup(a() As Integer)
Dim Maxv As Integer, maxp As Integer, I As Integer
Maxv = a(1): maxp = 1
For I = 2 To n
If a(I) > Maxv Then
Maxv = a(I): maxp = I
End If
Next I
Call move_f(a, maxp)
End Sub
Private Sub move_f(a() As Integer, k As Integer)
Dim I As Integer
For I = k To UBound(a) - 1
a(I) = a(I + 1)
Next I
ReDim Preserve a(UBound(a) - 1)
End Sub
x = 1
For i = 1 To m
'FOUND
x = i
x被重定义,此循环不会结束
-------------------------------------
fact(n)要求n为非负数
你的n一开始就是-1
那么在+1后,为0
那么1/0是无理数,所以会错
-------------
因为 item = 1 / fact(n)这儿就错了
所以
'FOUND
Loop While item >= 001
不成立
以上就是关于关于一道VB程序的改错全部的内容,包括:关于一道VB程序的改错、急求VB改错题答案、VB求改错!!!!!!!!等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)