VB关闭窗口提示“实时错误380”请问怎么解决,代码如下:
DimgotovalDimgointogotoval=Me.Height/2Forgointo=1TogotovalDoEventsMe.Height=Me.Height...
Dim gotoval
Dim gointo
gotoval = Me.Height / 2
For gointo = 1 To gotoval
DoEvents
Me.Height = Me.Height - 10
If Me.Height <= 11 Then GoTo horiz
Next gointo
horiz:
Me.Height = 30
gotoval = Me.Width / 2
For gointo = 0 To gotoval
DoEvents
Me.Width = Me.Width - 10
If Me.Width <= 11 Then GoTo horiz
Next gointo
Cancel = 1 展开
Dim gointo
gotoval = Me.Height / 2
For gointo = 1 To gotoval
DoEvents
Me.Height = Me.Height - 10
If Me.Height <= 11 Then GoTo horiz
Next gointo
horiz:
Me.Height = 30
gotoval = Me.Width / 2
For gointo = 0 To gotoval
DoEvents
Me.Width = Me.Width - 10
If Me.Width <= 11 Then GoTo horiz
Next gointo
Cancel = 1 展开
3个回答
展开全部
如果你是想实现关闭窗口时的动画就把最后一句Cancel = 1删掉
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim gotoval
Dim gointo
gotoval = Me.Height / 2
For gointo = 1 To gotoval
DoEvents
Me.Height = Me.Height - 10
If Me.Height <= 11 Then GoTo horiz
Next gointo
horiz:
Me.Height = 30
gotoval = Me.Width / 2
For gointo = 0 To gotoval
DoEvents
Me.Width = Me.Width - 10
If Me.Width <= 11 Then GoTo horiz
Next gointo
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim gotoval
Dim gointo
gotoval = Me.Height / 2
For gointo = 1 To gotoval
DoEvents
Me.Height = Me.Height - 10
If Me.Height <= 11 Then GoTo horiz
Next gointo
horiz:
Me.Height = 30
gotoval = Me.Width / 2
For gointo = 0 To gotoval
DoEvents
Me.Width = Me.Width - 10
If Me.Width <= 11 Then GoTo horiz
Next gointo
End Sub
展开全部
错误的地方是:Me.Width = Me.Width - 10
原因是:当width=10的时候跳转到 horiz 然后进入循环,然后执行Me.Width = Me.Width - 10 后 width =0,满足 <=11 条件,跳转到horiz,FOR 的终值 为0,但是一样会进入一次循环,这时候因为width=0 ,所以进入循环执行Me.Width = Me.Width - 10语句后 相当于Me.Width = 0- 10。给width属性赋了个负值,所以出错。
办法:
直接把后面这个GOTO 去掉,需要循环做什么事直接在下面退出循环后接着写。
原因是:当width=10的时候跳转到 horiz 然后进入循环,然后执行Me.Width = Me.Width - 10 后 width =0,满足 <=11 条件,跳转到horiz,FOR 的终值 为0,但是一样会进入一次循环,这时候因为width=0 ,所以进入循环执行Me.Width = Me.Width - 10语句后 相当于Me.Width = 0- 10。给width属性赋了个负值,所以出错。
办法:
直接把后面这个GOTO 去掉,需要循环做什么事直接在下面退出循环后接着写。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
哎哟,妈妈,一看到有 goto语句我就不想看了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询