Programming with Microsoft Visual Basic Create an Application

Programming with Microsoft Visual Basic Create an Application with Multiple Forms

Adding an Existing Form to a Solution • Add an existing form to Multiple. Forms/Harvey Industries Solution – Make sure that the added form uses a form name different from any form name of Harvey Industries Solution in • Visual Studio (Use Windows Form Designer to change (Name) property) • disk file system (xxx. vb) • The splash screen for Country Charming Inn is to be integrated into Harvey Industries Solution – The splash screen identifies the application’s author and copyright year, or shows welcome message 實作練習 : 需下載 Multiple. Forms/ Harvey Industries Solution 2 Multiple. Forms /Splash Solution ( replace main form’s name : frm. Main by frm. Splash, Main Form by Splash

Adding an Existing Form to a Solution Figure : Completed splash screen 3

Adding an Existing Form to a Solution 1. 2. Rename the form in Splash Solution Project->加入現有項目->Find Splash Form. vb to add Open a new form by Timer’s Tick event Add following codes in the Tick event of the timer tmr. Exit Me. Hide() Otherwise, the form frm. Main will show up tmr. Exit. Enabled = False many times. frm. Main. Show. Dialog() The name of the main Me. Close() form in Harvey Industries Solution 4 Syntax used to instruct the computer to create an object from a class: form. Dim variablename As New classname , e. g. , to create a Dim m. Form As New frm. Main. Show. Dialog()

Include Image File for the Added Form VB doesn’t import image files automatically for the added form. You can do it by one of the following steps Make the statement Me. pic. Country. Image = …… as a comment Click Splash Form’s Picture. Box pic. Country Use the task box of the Picture. Box to set up its image file (image file is in the Resources folder of the 5 Multiple. Forms/Splash Solution )

Assigning the Startup Form When an application is started, VB. NET automatically invokes the form set as the Startup object of a project The setup steps for Startup object are as follows: 1. Right click on the project in the Project Explorer Window to open the Properties Window 2. Click the Application tab in Properties Window 3. Click the Startup object Combo. Box to set up the startup form → choose frm. Splash 6

Show. Dialog() vs. Show() Method A form object’s Show. Dialog() method allows you to display the form object on the screen with focus transfer (dialog-style interaction) The syntax is: form. Show. Dialog() The form object’s Show() method allows you to display a form object on the screen without focus transfer The syntax is: form. Show () 7

Show Another Form by a Button Download Multiple. Forms/Playtime Solution, Multiple. Forms/Harvey Industries Solution How to use a button to open a new form 1. Project->加入現有項目->Find Playtime Form. vb to add 2. Include Image File for the Picture. Box 1 3. Add following codes in the Click event of a button Show The name of main form in Playtime on the Harvey Industries’ Main. Form Playtime Solution Dim p. Form As New frm. Playtime Me. Hide() Value passing p. Form. txt. Name. Text = Me. txt. Name. Text between two forms p. Form. Show. Dialog() Me. txt. Name. Text = p. Form. txt. Name. Text Value passing Me. Show() between two forms p. Form. Show() or. Show. Dialog() ‘Show 2 forms p. Form. Focus() (when using p. Form. Show() ) 8
- Slides: 8