如何从多个 VB6 .frm 文件中删除所有代码并保留表单设计?

发布于 2024-12-17 07:08:27 字数 105 浏览 2 评论 0原文

我有一个大型 VB6 应用程序,其中包含许多 .frm 文件。我想基本上从所有表单中“删除”代码,只留下 GUI 设计。

快速执行此任务的最佳方法是什么?

I have a large VB6 app with many .frm files. I want to basically 'gut' the code from all the forms and just leave the GUI design.

What would be the best way to perform this task quickly?

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

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

发布评论

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

评论(2

司马昭之心 2024-12-24 07:08:27

如果您确实有足够的表单,则不能只打开每个表单并 Ctrl + ADelCtrl + S 那么你总是可以编写一个快速的 VB 程序来完成它。 Visual Basic 将显示表单所需的信息放在文件的开头,后跟代码。将每个 .frm 文件复制到备份,打开它并将最后一个 Attribute ... 行之前的所有内容写入具有原始文件名的新文件中。相当脏,但应该只需要大约 15-20 分钟即可写入,并为您留下备份以防出现错误。

.frm 内容示例

VERSION 5.00
Begin VB.Form Form1
    Caption = "Form1"
    ClientHeight = 3195
    ClientLeft = 60
    ClientTop = 345
    ClientWidth = 4680
    LinkTopic = "Form1"
    ScaleHeight = 3195
    ScaleWidth = 4680
    StartUpPosition = 3 'Windows Default
    Begin VB.CommandButton Command1
        Caption = "Command1"
        Height = 495
        Left = 1800
        TabIndex = 1
        Top = 1320
        Width = 1215
    End
    Begin VB.TextBox Text1
        Height = 495
        Left = 360
        TabIndex = 0
        Text = "Text1"
        Top = 240
        Width = 1215
    End
End

Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
    Text1.Text = "Hello World"
End Sub
Private Sub Form_Load()
    Text1.BackColor = vbBlue
End Sub 

If you really have enough forms that you can't just open each form and Ctrl + A, Del, Ctrl + S Then you can always write a quick VB program to do it. Visual Basic puts the information needed to display the form at the beginning of the file followed by the code. Copy each .frm file to a backup, open it and write everything up to the last Attribute ... line to a new file with the original file name. Pretty dirty, but should only take about 15-20 minutes to write and leaves you a backup in case of error.

Sample .frm content

VERSION 5.00
Begin VB.Form Form1
    Caption = "Form1"
    ClientHeight = 3195
    ClientLeft = 60
    ClientTop = 345
    ClientWidth = 4680
    LinkTopic = "Form1"
    ScaleHeight = 3195
    ScaleWidth = 4680
    StartUpPosition = 3 'Windows Default
    Begin VB.CommandButton Command1
        Caption = "Command1"
        Height = 495
        Left = 1800
        TabIndex = 1
        Top = 1320
        Width = 1215
    End
    Begin VB.TextBox Text1
        Height = 495
        Left = 360
        TabIndex = 0
        Text = "Text1"
        Top = 240
        Width = 1215
    End
End

Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
    Text1.Text = "Hello World"
End Sub
Private Sub Form_Load()
    Text1.BackColor = vbBlue
End Sub 
征﹌骨岁月お 2024-12-24 07:08:27

我猜这是一个老问题,但如果您仍然对重构某些 VB6 项目感兴趣,请查看我的 VBFormDesign 过滤工具,网址为 http ://zoomicon.com/tranxform/

Guess this is an old question, but if you're still interested in refactoring some VB6 project, check out my VBFormDesign filter tool at http://zoomicon.com/tranxform/

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