|
-
Sep 2nd, 2011, 09:42 AM
#1
Thread Starter
Junior Member
Form Control
Hello,
I have a question. I have a couple of forms in my VB6 project. I have also been able to compile the project to generate an executable. However, i'm not sure how i can control which form i want to have displayed first when the executable is launched.
Say for example, i have two forms, frmOne and frmTwo. By default, when i run the executable, frmOne is the first one that gets displayed. But what i wish to know is if it is possible to have frmTwo come up first when the program is launched.
Any help is appreciated.
Thanks!
-
Sep 2nd, 2011, 09:48 AM
#2
Re: Form Control
On the Project menu select Properties, then change the "Startup Object".
-
Sep 2nd, 2011, 10:07 AM
#3
Thread Starter
Junior Member
Re: Form Control
Thanks for the reply si_the_geek. I have looked at the Properties under Project Menu. I found that for the Startup Object property, i have only two options in the drop down. One is 'None' and the other is 'Sub Main'. 'Sub Main' is a method right? I have looked at the forms and i can't seem to find where it is. Any advice?
-
Sep 2nd, 2011, 10:20 AM
#4
Re: Form Control
That is rather strange, the list normally contains "Sub Main" (which is a sub you create in a module) plus each of the forms in the project.
A quick check shows that you have probably created the 'wrong' kind of project. A normal project ("Standard Exe") shows them all, but others (such as "ActiveX Exe") show the list you are seeing.
I presume your project is an "ActiveX Exe", and unless you have a particular reason for choosing that I recommend you convert to a "Standard Exe" (you can select it next to the Startup Object).
-
Sep 2nd, 2011, 10:22 AM
#5
Thread Starter
Junior Member
Re: Form Control
Yes, the project is an ActiveX Exe. I probably will change that. Thanks again!
-
Sep 2nd, 2011, 10:31 AM
#6
Thread Starter
Junior Member
Re: Form Control
I'm afraid it has to be an ActiveX Exe.
-
Sep 2nd, 2011, 10:55 AM
#7
Thread Starter
Junior Member
Re: Form Control
Question again.
I have a form, called say 'frmOne'. This 'frmOne' has a menu bar on the top, with options saying 'One', 'Two', 'Three'. When any of these menu options are clicked upon, other menu lists pop up with more options. I would like to get rid of some of the menu options and keep some intact. I am not sure how to control the menu items. Any help please?
-
Sep 2nd, 2011, 10:58 AM
#8
Re: Form Control
Toggle their visible property perhaps?
-
Sep 2nd, 2011, 10:58 AM
#9
Thread Starter
Junior Member
Re: Form Control
I think i might have figured it out.
-
Sep 4th, 2011, 01:49 AM
#10
Re: Form Control
 Originally Posted by san_excalibur
I think i might have figured it out.
If you have solved the problem please mark the thread "Resolved".
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 6th, 2011, 11:27 AM
#11
Thread Starter
Junior Member
Re: Form Control
Actually, i'm not sure that i have resolved the issue. I can't seem to figure a way to control which form i want to display first when the application is run.
Another question: How can i delete a form from a VB6 project completely?
-
Sep 6th, 2011, 12:25 PM
#12
Re: Form Control
 Originally Posted by san_excalibur
Actually, i'm not sure that i have resolved the issue. I can't seem to figure a way to control which form i want to display first when the application is run.
Based on the options you've got, create a 'Sub Main' (and set it as the startup object), and in there have code to show the form you want.
Another question: How can i delete a form from a VB6 project completely?
Go to the Project explorer window and right-click on the form, then select "Remove".
The file will still exist wherever it was (so you may want to find + delete it), but it will not be part of the project.
-
Sep 6th, 2011, 01:14 PM
#13
Thread Starter
Junior Member
Re: Form Control
I'm sorry! I can't believe i'm this ignorant. I did right click on the form in the project explorer view, but i was looking for 'Delete', and i didn't pay attention to the 'Remove' option. Thanks si_the_geek!
I'm sorry i keep asking so many questions, but i have another one. I have a form, a very simple one with two command buttons that say 'Yes' and 'No'. What i want to do is when i click on 'Yes', i want to display another form.
I have tried 'frmName.Show', 'frmName.Show vbModal' and 'frmName.Show , Me' in the click event for that button, but it doesn't open up that form. Any help please?
-
Sep 7th, 2011, 02:31 AM
#14
Re: Form Control
Check the form name of the second form and make sure it is spelt correctly.
Either of those should work.
vb Code:
Private Sub Command1_Click() frmName.Show End Sub
or
vb Code:
Private Sub Command1_Click() frmName.Show vbModal, Me End Sub
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 7th, 2011, 10:16 AM
#15
Thread Starter
Junior Member
Re: Form Control
Thanks for the suggestion Nightwalker83. I have tried that. It doesn't seem to work though. Just to test, i tried to do that to other forms and it worked (the forms did show up), but it just doesn't work on the one form that i WANT to have show up on click of the button. Do you think there might be something stopping from that form from displaying?
-
Sep 7th, 2011, 08:16 PM
#16
Re: Form Control
Would you mind uploading the project so I can have a look at it? There is probably a problem with the event registering.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 9th, 2011, 10:43 AM
#17
Thread Starter
Junior Member
Re: Form Control
Nightwalker83, i'm not sure if i can upload the project as of now. But i will probably do that at a later time necessary. I still haven't been able to make the 'frmName.Show' to work.
However, i have a function in frmName with the code below:
<code>
Public Sub ShowFrmName()
On Error GoTo ErrPtnr_OnError
'Exit Sub
50010 With Me
50020 .ZOrder
50030 .WindowState = vbNormal
50040 .Show
50050 End With
Exit Sub
ErrPtnr_OnError:
Select Case ErrPtnr.OnError("frmName", "ShowFrmName")
Case 0: Resume
Case 1: Resume Next
Case 2: Exit Sub
Case 3: End
End Select
End Sub
</code>
Notice that i commented out the 'Exit Sub' code on line 3 so the program flow doesn't really exit the function. So now when i go to another form (say frmTwo) with a command button, in the click event for this button i wrote this code:
frmName.ShowFrmName
So when i click on the button in frmTwo, it does reveal the form frmName. However, frmName is displayed for about two seconds before it disappears again. I'm not sure what is causing this, but if i can get any help, i'd appreciate it. Also note that if, in the click event of the command button of frmTwo, i have frmName.Show (or frmName.Show vbModal or frmName.Show vbModal , Me), it does not display frmName at all.
-
Sep 10th, 2011, 01:17 AM
#18
Re: Form Control
Well, your code achieves opening the form like my code in post #14. Maybe the install of Visual Basic 6.0 is corrupt. Try reinstalling it and see if the problem persists.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 12th, 2011, 10:34 AM
#19
Thread Starter
Junior Member
Re: Form Control
I just tried that Nightwalker83. I re-installed VB6, but it didn't help. And now that same code which actually displayed the form for a few seconds doesn't do that anymore. So the form doesn't show up at all now when i click on the button. :/
I'm really sorry that something this simple is taking me so long to figure out, and that i keep asking questions about it. But i feel completely at sea here, and i need help with this.
-
Sep 12th, 2011, 10:42 AM
#20
Thread Starter
Junior Member
Re: Form Control
Actually, please disregard the part about the 'form not showing up at all' in my last post. I was looking at the wrong set up file. The form does show up, but it is only for a few seconds like before.
-
Sep 12th, 2011, 11:08 AM
#21
Thread Starter
Junior Member
Re: Form Control
Okay, so i'm not sure about what's going on with that form, but i am able to display OTHER forms on a button click.
So let's say i have three forms, FormOne, FormTwo and FormThree.
I have a button on FormOne, which upon clicking, i would like to display FormTwo. But like i explained, it only shows FormTwo for a few seconds before FormTwo vanishes. However, i am able to display FormThree upon clicking the button on FormOne.
Now i tried to check if i could get to FormTwo from a button in FormThree. But when i click on the button, i get an error message saying 'can't display non-modal form when modal form is displayed'.
Can anyone explain what modal forms and non-modal forms are, and what i can do to fix the above error?
Thanks!
-
Sep 12th, 2011, 11:59 AM
#22
Thread Starter
Junior Member
Re: Form Control
As per my previous post (post #21), i have fixed the error 'can't display non-modal form when modal form is displayed'. However, when i try to display FormTwo when a button on FormThree is clicked, the same thing happens. That is, FormTwo is displayed for a few seconds before it disappears. So i think there's something up with FormTwo.
-
Sep 12th, 2011, 12:00 PM
#23
Thread Starter
Junior Member
Re: Form Control
Hey! I think i might have fixed it! There was a timer set on another function in the same form. I got rid of the timer and that fixed it. Let me test some more and let you guys know.
-
Sep 12th, 2011, 02:01 PM
#24
Thread Starter
Junior Member
Re: Form Control
Yup, it works. I am now able to display FormTwo (as per post #21). Now i have a new question.
I have a list view on FormTwo. And i can add items to this list. Now, what i would like to do is this. When i click on a button in FormOne, i want to be able to view FormTwo with all the items in the list being displayed.
However, here is what is happening. When i click on the button in FormOne to display FormTwo, the list view displays nothing (even though there are items added to it). But when i close FormTwo, and click on the same button in FormOne again, it displays FormTwo again, but this time, with all of the items in the list view being displayed.
Does anybody know why this is happening? I would like to be able to see the items in the list view when i click on the button the first time, instead of displaying the form, closing it, and then reopening it.
Any help please?
-
Sep 12th, 2011, 05:21 PM
#25
Thread Starter
Junior Member
Re: Form Control
One more question. How can i define an event that occurs upon clicking the 'Enter' button and 'Delete' button from the keyboard?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|