Sub Main Problems

lucasite

Member
Joined
Dec 1, 2004
Messages
8
Programming Experience
3-5
Hi there,

simple problem. I added a module to my simple project. And inserted a public procedure call Main().

But when I type in:

Dim fMain as new frmMain

it says frmMain is not defined. However its definitely there in the project.
Coincidentally, I have another form, frmAbout, and that appears in the dropdown list, just not frmMain.

I dont understand why.

Anyone know?


Andy
 
Hi Andy!,

It may be due to the fact that you have changed the name of your form using the form properties to something else without changing the name in the solution explorer. What I mean to say is that say,You have created a form with the name frmMain which is shown on the solution explorer, but you have changed the name of the form to something else from the properties window of the form.


Thanks

Tonmoy
 
Last edited:
Hi Andy ,
em,sorry andy .. I cannot really get what you mean in your question. Do you have a form named "frmMain"? Because what you mentioned above is Main() method.
if you want to start a project with your Main() method,you need to go to properties window to change the start up page to "sub main" . In the Main(),write the code to control the form that you wanted to open.

hope i can help. :)

best regards,
pianonee.
 
Hi Pianonee,

yes thats what i did. I started a new project. Renamed form1 to frmMain. Added a module, and inserted into that a Sub Main() procedure. I changed the start properties of the project to start from sub main. but when I wrote Dim fMain as new frmMain in the Sub Main() procedure, it said that frmMain was not defined.

I think Tonmoy is probably right. It might well be a case of how Ive named the original form. But I was pretty sure I only changed the Name in the properties, and not in the solution window.

Will check it out shortly.

Thanks for the reply
 
try changeing dim fMain as new frmMain to dim fMain as new form1 (this is what everyone is referring to)

if that change does work, then here's what you do.
go to the Design of frmMain and in the properties of that form change the name from Form1 to frmMain and then change the sub main statement back to: dim fMain as new frmMain

VB names each form based on the class name of that form, in which if you change the file name (in solution explorer) the class name isnt changed as well
if you add an additional form to the solution VB names the new form's class name to the same thing as the file name for you.
 
Back
Top