VB.NET: Run loading wrong form  | |
October 10th, 2002, 01:55 AM
|
#1 (permalink)
| | Ordained Mommy
Join Date: Oct 2001 Location: Big Sky Country
Posts: 4,259
| VB.NET: Run loading wrong form
Okay this is my problem, qutie simple, code two opens the form of code 1 and I don't want that.
Basically what I am doing as I go through the book is im following along and creating the forms as I go along all in one project. But my problem is that i want the code to open up the approperaite
form and not the main form. How do i do this? its really a pain in the arse to delete all code then delete what I got in my form window and start over again, when later in the chapter
i need to go back to that example and add other code and then im back at repeating doing that all over again.
soooooo how do I keep the codes to that form to open that form and not the orignal first form?
here is the sample codes im using. Yes I added the line of windows stuff as well just not all that is inside the +.
TIA
Karin Code: Public Class frmAddition
Inherits System.Windows.Forms.Form
+Windows Form Designer generated code
Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
Dim sum As Double
sum = CDbl(txtFirstNum.Text) + CDbl(txtSecondNum.Text)
txtSum.Text = CStr(sum)
End Sub
End Class Code: Public Class frmExample3
Inherits System.Windows.Forms.Form
+Windows Form Designer generated code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
Dim quote1, quote2, quote As String
quote1 = "The ballgame isn't over, "
quote2 = "untill its over."
quote = quote1 & quote2
txtOutput.Text = quote & " Yogi Berra"
End Sub
End Class |
| |
October 10th, 2002, 02:21 AM
|
#2 (permalink)
| | Not Really a Member
Join Date: Oct 2001
Posts: 25,382
|
on the project name on the right side explorer, right click and hit properties. In there somewhere should be the startup properties. SEe if you can change the default to open up.
__________________
Helicopters don't fly; they vibrate so much and make so much noise that the earth rejects them.
|
| |
October 10th, 2002, 02:25 AM
|
#3 (permalink)
| | Ordained Mommy
Join Date: Oct 2001 Location: Big Sky Country
Posts: 4,259
|
Yes that is what i discovered just now before reading your post, but what doesn't make sense to me that if you have several forms in a project you have to change the startup properties each time you wnat to run the code in that form.
That seems like a pain and I don't see how in the future that could be good. I am wondering its related to another known bug.
So how do I make to so I don't have to change the startup properties each time for each form i wnat to load?
edit: Quote: |
***Deleted quote*** As it is not same thing is bug but not related to this problem.
|
Last edited by NeoStarO1 : October 10th, 2002 at 02:28 AM.
|
| |
October 10th, 2002, 02:32 AM
|
#4 (permalink)
| | Member
Join Date: Sep 2002
Posts: 364
|
You can't run code in multiple forms as standalone because only one class can have a main() method. |
| |
October 10th, 2002, 02:34 AM
|
#5 (permalink)
| | Not Really a Member
Join Date: Oct 2001
Posts: 25,382
|
No you don't change forms in the properties to show different forms. That setting only changes the STARTUP form.
From there you call code in the startup form to open the 2nd form.
Definately not a bug  |
| |
October 10th, 2002, 02:39 AM
|
#6 (permalink)
| | Member
Join Date: Sep 2002
Posts: 364
|
Vass--I think her frustration has to do with that fact that a Windows application automattically adds a form with a main method.
Now what I have done at times is delete the main method if I have started with a Windows app, make an empty class with a main, and then show a form. Sometimes a form may or may not need to be shown for whatever reason. |
| |
October 10th, 2002, 02:40 AM
|
#7 (permalink)
| | Ordained Mommy
Join Date: Oct 2001 Location: Big Sky Country
Posts: 4,259
| Quote: Originally posted by vass0922 No you don't change forms in the properties to show different forms. That setting only changes the STARTUP form.
From there you call code in the startup form to open the 2nd form. 
Definately not a bug | What do you mean call code?
Meaning i need to stay at orignal form code window and call form to second set of codes inserted in code one with a call ? |
| |
October 10th, 2002, 02:44 AM
|
#8 (permalink)
| | Not Really a Member
Join Date: Oct 2001
Posts: 25,382
|
well that's fine, but she's still learning programming and following a book so let her follow the book and not try to confuse things further lol.
So you gotta have one startup form, and then the startup form calls the 2nd form on some sort of event or some sort of code. |
| |
October 10th, 2002, 02:51 AM
|
#9 (permalink)
| | Ordained Mommy
Join Date: Oct 2001 Location: Big Sky Country
Posts: 4,259
| |
| |
October 10th, 2002, 02:55 AM
|
#10 (permalink)
| | Not Really a Member
Join Date: Oct 2001
Posts: 25,382
|
for instance to show a 2nd form in my app I have something like...
Dim fSplash As New frmSplash()
fSplash.Show()
now one way to call code in teh 2nd form is to put stuff in the Form Load event .. not hte classiest code but it'll work  |
| | | Thread Tools | Search this Thread | | | | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |