Link to home
Start Free TrialLog in
Avatar of jl_forum
jl_forum

asked on

Really easy question about .frm file

Hi all,
    This is a really stupid question. I have a .frm form (no other forms) and I need to get it to run. I am running VB6 and am not quite sure what to do. I tried creating a new project in an executable, etc., but the same problem exists. I create the project, right-click the form and say view code. I then paste the .frm code I have and for some reason, the following two lines turn red:

Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form LoadMyForm

All the lines that start with "Begin" are red. In addition, the first four lines actually say

VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form LoadMyForm
   Caption         =   "Form1"

but the version line changes to "VERSION5#". Am I placing this part into the wrong file? What do I do to correct this? The rest of the file seems to work after the variable Dim's are declared. In fact, the last red lines are as follows:

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

What do I do to get it to run? Thanks and sorry about the stupidity.
           Sincerely,
                       JL
Avatar of Erick37
Erick37
Flag of United States of America image

To add a .frm file to your project, start VB.

GoTo Project->Add form_>[Existing]

Browse for the .frm on your project, then click OK

Then the form is added to your project.

To view the code, right click the form in the Project pane, then select "View Code"

That's it!

Let me clarify (it's late here)...

To add a .frm file to your project:

Start VB with a new project.  Form1 is created by default.

In the menubar select:   Project->Add Form->[Existing]

Browse for the .frm file on your computer, then click OK
(If the name of the form happens to be Form1.frm, then rename the already open Form1 to something else)

The form is then added to your project.

To view the code, right click the form in the Project pane, then select "View Code"

That's Better.
Avatar of jl_forum
jl_forum

ASKER

Hi Erick37,
    Actually, the problem isnt in viewing the code. I actually have the .frm file in a text file. One of the problems is that I dont know what the actual file is called. I assume that it is LoadMyForm.frm. The other problem is that a lot of the text is red (errors). When I try and compile it with just the .frm file, it says:
Compile error: Invalid outside procedure
on the VERSION 5.00 that got changed to VERSION 5#. The red text i the Object = and Begin lines as stated above. I have no problem viewing the code, I just need to know how to compile/execute it. Thanks.
             Sincerely,
                   JL
Heres an example... if I had the data from the webpage http://www.codeguru.com/vb/gen/vb_forms/listviewcontrols/article.php/c5947/ and wanted to compile it without downloading the zipfile at the bottom, how would I do it? I get the second and third lines in red, the "Begin" lines in red, and when I try and compile, it says Invalid Outside Procedure.
What I did was create a new project, add a form, and copy and paste the data. Then I try and compile. What am I doing wrong? Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Erick37
Erick37
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Erick37. It doesn't work with the stuff before "Attribute =", so I need to recreate that stuff. Perhaps I'm asking a little too much, but how do I go around creating those items? Additionally, theres a declaration of stuff as ADODB.blahblah. Do I have to put in a reference? If so, which one? The MS ADO? Finally, for the form, there is a "Begin MSAdodcLib.Adodc". What is this referring to and how do I create it? Thanks much! I'm upping the points because I'm asking so much. =)
The example you pointed to at CodeGuru is actually 2 modules: one form and one class module.

This is the beginning of the class module file:
VERSION 1.0 CLASS
BEGIN


It's better to download the zipped project to a separate directory, then unzip.
http://www.codeguru.com/code/legacy/vb_forms/MBTLVI.zip

Double click on  Project1.vbp to open the entire project.

Good Luck!
All the info is in the .frm file.

Paste the .frm here and we'll see how to open it.  If you do not want to paste the code, then paste the header (everything up to and including the last "Attribute = " line)

I'll check back tomorrow.
Hi Erick,
    The problem is that I am not using that example, thus I do not have a zip file or vbp. I just have the .frm that I have involved. Help! =)
                Sincerely,
                       Jon
Hi Erick, as requested:

VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form LoadMyForm
   Caption         =   "Form1"
   ClientHeight    =   9000
   ClientLeft      =   150
   ClientTop       =   300
   ClientWidth     =   10000
   LinkTopic       =   "Form1"
   ScaleHeight     =   10000
   ScaleWidth      =   12000
   StartUpPosition =   3  

   Begin VB.CommandButton Command1
      Caption         =   "Command1"
      Height          =   495
      Left            =   8000
      TabIndex        =   4
      Top             =   3500
      Width           =   1000
   End
   Begin VB.CommandButton Command2
      Caption         =   "Command2"
      Height          =   495
      Left            =   7000
      TabIndex        =   6
      Top             =   6000
      Width           =   1000
   End
   Begin VB.CommandButton Command3
      Caption         =   "Command3"
      Height          =   495
      Left            =   6000
      TabIndex        =   4
      Top             =   1000
      Width           =   1000
   End
   Begin VB.CommandButton cmdEat
      Caption         =   "&Eat"
      Height          =   495
      Left            =   400
      TabIndex        =   0
      Top             =   120
      Width           =   1200
   End
   Begin VB.CommandButton cmdSit
      Caption         =   "&Sit"
      Height          =   495
      Left            =   750
      TabIndex        =   0
      Top             =   120
      Width           =   1200
   End
   Begin VB.CommandButton cmdMonster
      Caption         =   "&Monster"
      Height          =   495
      Left            =   3000
      TabIndex        =   3
      Top             =   100
      Width           =   1200
   End
   Begin MSAdodcLib.Adodc Adodc1
      Height          =   495
      Left            =   7500
      Top             =   120
      Width           =   3000
      _ExtentX        =   5000
      _ExtentY        =   1000
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   2
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   3
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   "DSN=MonsterDSN"
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   "MonsterDSN"
      OtherAttributes =   ""
      UserName        =   "Monster"
      Password        =   "Monster"
      RecordSource    =   "JAR_WALL"
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSAdodcLib.Adodc Adodc2
      Height          =   855
      Left            =   9000
      Top             =   4000
      Width           =   1500
      _ExtentX        =   2500
      _ExtentY        =   1500
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   "Provider=OraOLEDB.Oracle.1;Persist Security Info=False;User ID=mango"

      OLEDBString     =   "Provider=OraOLEDB.Oracle.1;Persist Security Info=False;User ID=mango"
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc2"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.TextBox Text1
      Height          =   975
      Left            =   0
      TabIndex        =   2
      Text            =   "Text1"
      Top             =   600
      Width           =   7000
   End

   Begin VB.PictureBox Picture1
      AutoRedraw      =   -1  'True
      Height          =   9000
      Left            =   0
      ScaleHeight     =   9000
      ScaleWidth      =   7000
      TabIndex        =   1
      Top             =   1800
      Width           =   7000
   End
   Begin VB.OLE OLE1
      Height          =   1000
      Left            =   4200
      TabIndex        =   5
      Top             =   4800
      Width           =   3000
   End
End
Attribute VB_Name = "LoadMyForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Please help if possible. Thanks.
              Sincerely,
                      JL
If that is the ENTIRE contents of the .frm file, then what you have contains NO CODE whatsoever, just the definitions of the various controls (Buttons, Picture Box, ADO Data Controls) that have been drawn on the form.  This will be of little or no use to you without the associated code that makes the application work.

AW
for example, here is a SIMILAR listing of the contents of a .frm file that I have used in a Demo program:

VERSION 5.00
Begin VB.Form frmEditPerson
   Caption         =   "Edit Person"
   ClientHeight    =   2595
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4440
   LinkTopic       =   "Form1"
   ScaleHeight     =   2595
   ScaleWidth      =   4440
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdApply
      Caption         =   "Apply"
      Enabled         =   0   'False
      Height          =   390
      Left            =   3360
      TabIndex        =   10
      Top             =   2160
      Width           =   975
   End
   Begin VB.CommandButton cmdCancel
      Caption         =   "Cancel"
      Height          =   390
      Left            =   2160
      TabIndex        =   9
      Top             =   2160
      Width           =   975
   End
   Begin VB.CommandButton cmdOK
      Caption         =   "OK"
      Enabled         =   0   'False
      Height          =   390
      Left            =   960
      TabIndex        =   8
      Top             =   2160
      Width           =   975
   End
   Begin VB.TextBox txtBirthDate
      Height          =   330
      Left            =   960
      TabIndex        =   4
      Top             =   1185
      Width           =   1815
   End
   Begin VB.TextBox txtName
      Height          =   330
      Left            =   960
      TabIndex        =   2
      Top             =   615
      Width           =   3375
   End
   Begin VB.TextBox txtSSN
      Height          =   330
      Left            =   960
      TabIndex        =   0
      Top             =   105
      Width           =   1815
   End
   Begin VB.Label Label4
      Caption         =   "Age"
      Height          =   255
      Left            =   120
      TabIndex        =   7
      Top             =   1755
      Width           =   735
   End
   Begin VB.Label lblAge
      BorderStyle     =   1  'Fixed Single
      Height          =   330
      Left            =   960
      TabIndex        =   6
      Top             =   1680
      Width           =   975
   End
   Begin VB.Label Label3
      Caption         =   "Birthdate"
      Height          =   255
      Left            =   120
      TabIndex        =   5
      Top             =   1245
      Width           =   735
   End
   Begin VB.Label Label2
      Caption         =   "Name"
      Height          =   255
      Left            =   120
      TabIndex        =   3
      Top             =   690
      Width           =   735
   End
   Begin VB.Label Label1
      Caption         =   "SSN"
      Height          =   255
      Left            =   120
      TabIndex        =   1
      Top             =   180
      Width           =   855
   End
End
Attribute VB_Name = "frmEditPerson"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private WithEvents mobjPerson As Person
Attribute mobjPerson.VB_VarHelpID = -1

Private Sub cmdApply_Click()

  ' save the object
  mobjPerson.ApplyEdit
  mobjPerson.BeginEdit

End Sub

Private Sub cmdCancel_Click()

  ' do not save the object
  mobjPerson.CancelEdit
  Unload Me
 
End Sub

Private Sub cmdOK_Click()

  ' save the object
  mobjPerson.ApplyEdit
  Unload Me

End Sub

Private Sub Form_Load()

  Set mobjPerson = New Person
  EnableOK mobjPerson.IsValid
  mobjPerson.BeginEdit
 
End Sub

Private Sub mobjPerson_NewAge()

  lblAge = mobjPerson.Age

End Sub

Private Sub txtBirthdate_Change()

  If IsDate(txtBirthDate) Then mobjPerson.Birthdate = txtBirthDate

End Sub

Private Sub txtName_Change()

  mobjPerson.Name = txtName

End Sub

Notice that AFTER the block that reads


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

is a Block that contains the code that makes the Form behave as it was designed to.  Without that code, the form is FUNCTIONLESS.

AW
Hi JL,

I just copied your code into Notepad and then saved it to disc as Form1.frm.

I opened VB and started a new project.  I was able to add this form to the project and open it without error.  This means that all of the controls added at design time are valid.

What errors were you getting?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi guys, thanks for your comments. I totally appreciate all  your help on this.

Arthur: Actually, I did not paste the entire code, just the form controls. The form controls are the only part I am really having an issue with though. It keeps giving me errors when I try and compile it. The form controls don't appear in the design aspect of it either.

Erick: You got it to work? Did you paste it all into one big .frm file? I did it as one big .frm file and like I said before, the "Version 5.00" becomes "Version 5#" and
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form LoadMyForm
becomes highlighted in red. All the "Begin" lines are in red as well. Perhaps you are doing it differently than me? Do you actually see form controls appear? I'm sorry that I am not understanding this well.

aParser: I am going through this trouble because I only have the form file and wish to compile this. My code is similar to that of which Arthur put up. The .frm is divided into two sections similar to what his is. All that is supposed to be within the same .frm file correct? There is no classes in my file. Rather, it is like Arthurs. The format is as follows:

{what I pasted above}
Option Explicit
Dim...
Dim...
.
.
.
Private Sub()
End Sub
Private Sub()
End Sub
.
.
.
Like I stated before, the lines become red and when I try and compile it, I get the "Compile error: Invalid outside procedure"
error.

Sorry guys, I guess I'm really stupid about this or not understanding what you mean. I am trying to specify it as much as possible. I appreciate all your help. Please dont give up on me! =)
                 Sincerely,
                       JL
What we're saying is that you can't create a form in the VB IDE and paste in the stuff above "Option Explicit".

It's not entirely clear to me if you have all of this stuff in a file on your system or if you're getting it from somewhere else like the CodeGuru site.

If it's from somewhere else, paste everything into a Notepad document and save it with a .FRM extension, then start VB6 and add the file to your project.

If it's already on your system, make sure the file has a .FRM extension and then just add the file to the project.  (Erick37's second comment explains how to add a file to a project.)

Again, you can't paste everything you've shown into a form when it's open in the IDE.
Hmm... I believe I tried that yesterday. In other words, just save my entire contents into a .frm file, create a new project, and add an existing form, correct? If so, I still get the red lines as stated previously and it doesn't want to compile. Is there something else I need to add (reference or something)? When I add the form as an existing form, the design view is still empty. I don't see any buttons or anything. Thanks again for your help!
What you describe sounds correct.  I'm surprised that you're still able to see things like "VERSION 5.00" and "Attribute VB_Exposed = False" ... but then again, I suppose you are, too, and that's the point. :)

As far as references go, you might try adding the "Microsoft ADO Data Control 6.0" under Components before adding the .FRM.

I'm trying to think of reasons why the VB IDE might still be unhappy with the file, but I'm starting to grasp at straws.  There could be some strange line breaks in the file.  It could be some kind of versioning issue; you might try downloading the latest service pack for VB.  It could be that the controls on the form aren't registered in your system -- but the only "non-standard" control appears to be the ADO Data Control.  You can search your registry for the GUID you pasted: {67397AA1-7FB1-11D0-B148-00A0C922E820} .  If it's missing, make sure that the MSADODC.OCX is on your system and register it.  I don't know if the latest MDAC would have any affect on that control.  I was also worried that there might be something in a .FRX, but I don't see anything.

The strangest thing is that Erick37 did the exact same thing and got no error. ... And now I've tried it and gotten it to work.  And the project automatically added the reference to the ADO Data Control to the project when I added the form.

Check whether the OCX is on your system and registered.  If it is, I'm stumped.
Close Visual Basic.

Open Nopepad or any TEXT editor.

Paste the code in the text file (in Notepad), then save the file as filename "MyForm.frm"

Close Notepad.

Open VB, then add the FILE to the project, using the first instructions from yesterday.

(Do not paste the code in the code window while in the VB editor - that will not work!)
Hmm... good point aParser. I'm actually on a different computer but I will try it when I get back and report on what's up. Erick, thats exactly what I did. Again, those errors appeared and all that described above. Hopefully it is what aParser pointed out? I dont understand why the "Begin" lines would be red as well though... any ideas? Thanks guys, I really like this forum and am glad there are people like you all so dedicated to helping others! =) Much obliged!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hey guys, it seemed to work! Thanks! The problem was that the OCX file wasn't existent and registered. I guess I hadn't done the correct thing with pasting it into an .frm outside the IDE as well (I swear I did), but I got everything good and going! Thanks!! =) Now my other question to you all is how do I split points amongst you all? You all helped so much. Thanks all for helping a newbie!
                 JL
Thanks all! =)