How to remove all code from multiple VB6 .frm files and leave form design?

后端 未结 2 494
不思量自难忘°
不思量自难忘° 2021-01-27 07:26

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

2条回答
  •  情深已故
    2021-01-27 08:14

    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 
    

提交回复
热议问题