VB6默默地从表单中删除大量的控制数据

发布于 2024-07-16 19:19:13 字数 1013 浏览 6 评论 0原文

我的项目在 SSTab(4 个选项卡)中可能有 130 个控件(所有标签、文本框等的总数)。 该项目加载良好,运行良好,我在任何时候都没有看到任何错误或警告,但是当我保存带有 SStab 的表单时,SStab 数据不会保存(它完全消失了)。 通常 .frm 文件的相关部分如下所示:

   Begin TabDlg.SSTab SSTab1 
     Height          =   8895
     [1550 more lines of code for all the controls]
     Width           =   540
   End
   Begin VB.Menu FileMenu

但最近它被裁剪为:

   Begin TabDlg.SSTab SSTab1 
   Begin VB.Menu FileMenu

这非常令人沮丧! 在我的 VB IDE 中,框架、sstab 和所有控件都在那里,可编辑、运行/编译良好,任何时候都没有错误消息,但是当您保存文件时,1550 行宝贵的 sstab 数据就消失了 - 再次,没有警告或错误消息。 因此,如果退出并重新启动 IDE,您会收到表单加载错误,因为现在缺少 60% 的代码。 日志文件指向它找到的第一个错误(在本例中是没有 End 的 Begin TabDlg) - 其中没有其他信息。 (日志文件是在代码被删除并保存后生成的,因此它没有任何帮助是有道理的。)

当我第一次发布这个问题时,我认为这与控件的数量有关,因为它出现在我添加了一个控件,在最初的几次测试中,当删除该控件(或其他控件)时,该控件似乎消失了。 现在,我似乎无法在任何情况下保存该表单,即使我删除了许多控件(使控件的数量远远低于上次稳定时的数量)。

我还尝试删除 SStab 并将所有控件移动到 4 个不同的框架。 我在 IDE 中成功做到了这一点,但当我保存时,大量数据(从滑块控件开始)丢失了。 所以我根本不知道发生了什么。

该问题可以在两台不同的 PC 上重现,因此它似乎不是硬件/损坏的软件 VB 安装问题。

还有其他人遇到过这样的事情吗?

My project has maybe 130 controls (total of all labels, textboxes, etc.) in an SSTab (4 tabs). The project loads fine, it runs fine, I don't see a single error or warning at any point, but when I save the form with the SStab on it, the SStab data isn't saved (it is completely gone). Normally the relevant portion of the .frm file looks like this:

   Begin TabDlg.SSTab SSTab1 
     Height          =   8895
     [1550 more lines of code for all the controls]
     Width           =   540
   End
   Begin VB.Menu FileMenu

But lately it's getting cropped to:

   Begin TabDlg.SSTab SSTab1 
   Begin VB.Menu FileMenu

This is very frustrating! In my VB IDE, the frame, sstab, and all the controls are there, editable, running/compiling fine, no error messages at any point, but when you save the file, 1550 lines of precious sstab data just disappears - again, with no warning or error messages. So if you exit and restart the IDE, you get a form load error because 60% of the code is now missing. The log file points to the first error it finds (in this case a Begin TabDlg with no End) - there's no other info in it. (The log file was generated after the code was deleted and saved, so it makes sense that it wouldn't be helpful.)

When I first posted this question, I thought it had to do with the number of controls, because it appeared after I added a control, and in my first few tests, seemed to disappear when that control (or other controls) was deleted. Now I can't seem to get that form to save under any circumstances, even when I delete many controls (bringing the number of controls far below where it was when it was last stable).

I also tried deleting the SStab and moving all the controls to 4 different frames. I successfully did that in the IDE, but when I saved, a huge chunk of the data (starting with a slider control) was missing. So I have no fraking idea what is going on.

The problem is reproducible on two different PCs, so it doesn't appear to be a hardware/corrupt software VB install issue.

Has anyone else run into something like this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

怂人 2024-07-23 19:19:13

为每个选项卡创建一个 UserControl。 这使得编辑变得更加容易。 它还允许您很好地模块化代码,因此每个选项卡都位于自己的文件中,并且如果您愿意,它还允许您在其他地方重用选项卡。

Create a UserControl for each tab. That makes editing MUCH easier. It also allows you to nicely modularize the code, so each tab lives in its own file, and it'll allow you to reuse tabs elsewhere if you want.

橘寄 2024-07-23 19:19:13

听起来很可怕,从来没有听说过这样的事情。

当您在表单损坏之前将表单加载到 IDE 中时,您可能没有从 VB6 获得错误日志文件? 日志文件与表单文件具有相同的文件名,但文件扩展名为 .log。 例如,如果加载 Myform.frm 时发生错误,Visual Basic 将创建一个名为 Myform.log 的日志文件。 您可能会看到的错误消息已记录在手册中。

查看 Windows 事件日志,看看它是否记录了针对 VB6 IDE 的任何有趣问题?

您是否使用过任何奇怪的控件? 也许其中之一以某种方式破坏了 FRM 或 FRX。 正如您显然知道的那样,FRM 文件只是文本。 该格式记录在 VB6 手册中。 您能在文本编辑器中看到 FRM 中的任何损坏吗? 如果删除 FRX 中定义的任何属性,它是否仍然会失败。

我想我会尝试创建一个新项目和一个新表单,然后使用 IDE 将所有控件定义复制并粘贴到其中 - 无需代码。 尝试一下新的表单,看看是否有同样的问题。 也许您可以通过这种方式重新创建表单而不会出现问题。 如果新窗体确实有问题,请执行相同的操作,但只使用一半的控件。 也许你可以通过“二分查找”找到问题控制。

Sounds horrible, never heard of anything like that.

Presumably you aren't getting an error log file from VB6 when you load the form into the IDE before it gets corrupted? The log file has the same filename as the form file but with a .log filename extension. For example, if errors occurred when loading Myform.frm, Visual Basic would create a log file named Myform.log. The error messages you might see there are documented in the manual.

Have a look in the Windows Event Log, see whether it records any interesting problems against the VB6 IDE?

Are you using any weird controls? Maybe one of them is somehow corrupting the FRM or FRX. FRM files are just text as you obviously know & the format is documented in the VB6 manual. Can you see any corruption in the FRM in a text editor? If you remove any properties defined in the FRX, does it still fail.

I think I would try creating a new project and a new form, and then use the IDE to copy and paste all the control definitions into it - no code. Play with the new form, see whether it has the same problem. Maybe you can recreate the form this way without the problem. If the new form does have the problem, do the same thing but only take half the controls. Maybe you can find a problem control by "binary search".

小草泠泠 2024-07-23 19:19:13

当 .FRM 可写但 .FRX 只读时尝试保存表单时,我遇到了同样的问题

I get the same problem when attempting to save a form when the .FRM is writable but the .FRX is read-only

梦情居士 2024-07-23 19:19:13

不确定这是否是问题所在,但在 VB6 窗体上,命名控件的数量限制为 255 个(或者是 256 个)。 也许你正在遇到这种情况?

解决该限制的一种方法是使用控制数组。 例如,如果您有 10 个标签,而不是 label1、label2、label3 等,则可以执行 label(0) 到 label(9),并仅使用一个命名控件。

关于 SSTAB 值得一提的另一件事是它显示/隐藏控件的方式。 虽然控件看起来可能位于单独的选项卡上,但实际发生的情况是控件正在向左移动(因此在视图之外)。 也许有这么多组件,SSTAB 在 IDE 中尝试在设计视图中渲染控件时会感到窒息?

同样,不确定这是否是问题所在,但我知道这两个花絮相对未知。

Not sure if this is the issue, but on a VB6 form, there is a limit to 255 (or is it 256) named controls. Perhaps you are running into that?

One way around that limitation is to use control arrays. For example, if you had 10 labels, instead of label1, label2, label3, etc, you could do label(0) through label(9), and use up only one named control.

The other thing worth mentioning about the SSTAB is the way it shows/hides controls. While it may appear that the controls are on separate tabs, what is really happening is that the controls are getting moved waaaayyyyy to the left (and consequently out of view). Perhaps with so many components, the SSTAB is choking on this in the IDE as it tries to render the controls in design view?

Again, not sure if this is the issue, but I know these two tidbits are relatively unknown.

她比我温柔 2024-07-23 19:19:13

所以SAVE功能不起作用。

我怀疑您放置在标签条上的组件之一是罪魁祸首。

所以..

1) 清点表格上的每一种组件

2) 消除一种(种类),保存

3) 它保存了吗?

-> 是的 = 那是有问题的控制

-> 否 = 返回步骤 2,但选择另一种类型

当然,删除步骤 #2 中某种类型的所有控件(例如,所有标签或所有文本框等)很重要。

然而我从未听说过这种情况发生。

So the SAVE function is not working.

I suspect one of the components you are placing on the tab strip is the culprit.

So ..

1) Take an inventory of each and every kind of component you are placing on the form

2) eliminate one (kind), SAVE

3) Did it SAVE?

-> Yes = that was the problematic control

-> No = return to step 2, but pick another kind

Of course, its important to remove all controls of a certain kind in step #2 (for example, ALL labels, or ALL textboxes, etc).

I have never heard of this happening however.

原野 2024-07-23 19:19:13

你并不孤单! 我见过这个问题。 。 .事实上,我现在正在处理它,这就是我来到这个网站的原因。

我从 94 年开始就开始使用 VB(VB3),大约 5 或 6 年前我第一次看到这个问题,当时使用的是 VB6。 我的解决方案与您从上面回复的好人那里收到的一些建议没有什么不同:扔掉现有文件并在新文件中重建表单。 我又这么做了,受影响的表格从那时起就一直有效。

我当前的问题以另一种更新的形式出现,并且替换/重建选项(大约一个月前执行)只工作了大约三周。 现在问题又回来了,文件的每次新迭代都会很快损坏。 根据上面关于允许的控件总数的答复,我正在研究我有多少控件。 。 而且,碰巧的是,我正在将主要按钮和菜单合并到控制数组中,只是因为这将简化它们的管理。

我还可以确认您关于将项目转移到第二台电脑的意见。 。 。 我也这么做了,问题依然存在。 此外,我可以补充一点,我已将项目从一个共享存储系统移动到另一个共享存储系统,但无济于事。 (原始存储位置位于安装到 Win-tel 系统的驱动器上,新位置位于基于 UNIX 的 NAS 上!)

只需再次重建文件并检查:Controls.Count = 62,所以我离255控制极限前面提到过。 这确实很奇怪! (更不用说令人沮丧了!)

You are not alone! I've seen this problem. . .in fact I'm dealing it right now, which is what brought me to this site.

I've been working with VB since '94 (VB3) and I first saw this problem about 5 or 6 years ago, while using VB6. My solution then, was not unlike some of the suggestions that you have recieved from the good folks who've responded above: throw out the existing file and rebuild the form in a new file. I did that back and the affected form has worked ever since.

My current problem is appearing in another, much newer form, and the replace/rebuild option (performed about a month ago) only worked for about three weeks. Now the problem is back and each new iteration of the file gets corrupted very quickly. Following the reply above regarding the total number of allowable controls, I'm looking into just how many controls I have. . .and, as it happens, I was in the process of consolidating the primary the buttons and menus into control arrays, simply because it was going to streamline their management.

I can also confirm your observations about moving the project to a second PC. . . I've done that too, and problem persists. Moreover, I can add that I have moved the project from one shared storage system to another to no avail. (The original storage location was on a drive mounted to a Win-tel system and the new location is on a UNIX-based NAS!)

Just rebuilt the file again and checked: Controls.Count = 62, so I am no where near the 255 control limit mentioned previously. This is indeed strange! (Not to mention furstrating!)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文