VB6程序获取错误340卸载表格后,控制数组元素'0'不存在 [英] VB6 program gets err 340 Control array element '0' doesn't exist after unload of form
问题描述
我们有一个大型的vb6程序,它具有多种形式.
我们需要加载然后卸载大约3种表格.
在卸载了1个并且只有1种特殊形式后,我们得到340个控制数组元素在frmStoreControls.fraBase(0).Left
上不存在,但在frmStoreControls.fraBase(1).Left
上不存在
fraBase
是在设计时间frmStoreControls.txtOrderStatusCodesAs1(0).Left
中定义的框架控制数组,该数组在fraBase(0)
中不会产生错误.
我不明白发生了什么.
任何人都可以解释一下,如何解决?
谢谢
We have a large vb6 program that has many forms.
We have the need to load then unload about 3 forms.
After unloaded 1 and only 1 particular form we get 340 Control array element doesn''t exist on frmStoreControls.fraBase(0).Left
but NOT on frmStoreControls.fraBase(1).Left
fraBase
is a frame control array defined at design time frmStoreControls.txtOrderStatusCodesAs1(0).Left
which is in fraBase(0)
does NOT generate an error.
I do not understand what is happening.
Can anyone please explain and how can this be fixed?
Thanks
推荐答案
我在两个程序中的某些文本框都遇到了相同的问题.他们在第一次加载表单时就可以很好地加载,但是当我重新加载表单(当然是在卸载命令之后)以及使用"textbox(xx).setfocus"时,我一直收到"340错误"的提示.方法.经过数小时的搜索,我发现错误仅是在我声明了对象变量(以其称为LastObject
)的特定形式下生成的单击按钮后,可以使用重置上一个使用的文本框的焦点.
让我们看一下代码:
暗
LastObject作为对象
私人子
Form_Activate()
设置
LastObject = InpText(1)
InpText(1).SetFocus
结束子
这触发了"340控制阵列...错误".因此,经过数小时的搜索(如我之前所述),我发现如果在之后分配了LastObject值,则会加载并激活表单,或者在完成对控件中所有控件的操作后Form_Activate子,我没有错误.例如,这:
私人子
Form_Activate()
InpText(1).SetFocus
等等等等
等等等等
设置
LastObject = InpText(1)
结束子
...或这个:
私人子
Form_Activate()
InpText(1).SetFocus
等等等等
等等等等
SetLastObject
结束子
私人子
SetLastObject()
设置
LastObject = InpText(1)
结束子
...两个程序现在在我的程序中都可以正常工作.
希望对您有所帮助.
I had the same issue with some textboxes in two of my programs. They would load just fine the first time that the form was loaded, but I kept on getting a "340 error" when I reloaded the form (after an unload command, of course) and when used the "textbox(xx).setfocus" method. After hours of searching, I found out that the error was generated only in specific forms in which I had declared an object variable (let''s call itLastObject
) that I use in order to reset the focus at the last used textbox, after clicking on a button.
Let''s see the code:
Dim
LastObjectAs Object
Private Sub
Form_Activate()
Set
LastObject = InpText(1)
InpText(1).SetFocus
End Sub
This triggered the "340 Control array... error". So, after hours of searching (as I said before), I found that if I assigned the LastObject value after the form was loaded and activated, or after I was done with all the manipulations of the controls in the Form_Activate sub, I got no error. For instance, this:
Private Sub
Form_Activate()
InpText(1).SetFocus
blah blah
blah blah
Set
LastObject = InpText(1)
End Sub
...or this:
Private Sub
Form_Activate()
InpText(1).SetFocus
blah blah
blah blah
SetLastObject
End Sub
Private Sub
SetLastObject()
Set
LastObject = InpText(1)
End Sub
...both work just fine in my programs now.
I hope this was helpful.
这篇关于VB6程序获取错误340卸载表格后,控制数组元素'0'不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!