I have multiple VB6 .frm
files. See example below. I want to strip away the functions and subs from the code and leave only the form design.
What I need to do is find the last line starting with "Attribute" because after this line everything further should be deleted.
Using pattern matching or something similar, how can I process the .frm
files so that everything after the last Attribute line is deleted? If I am traversing through a file, how can I tell where the last Attribute line is?
Example of .frm
file:
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