Download presentation
Presentation is loading. Please wait.
Published byMeghan Kennedy Modified over 6 years ago
1
Programming with Microsoft Visual Basic 2012 6th Edition
Create an Application with Multiple Forms
2
Adding an Existing Form to a Solution
Add an existing form to Chap07/Harvey Industries Solution Make sure that added form uses a different form name 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 實作練習 : 需下載 Chap07/ Harvey Industries Solution Chap07/Splash Solution Chap07/Playtime Solution
3
Adding an Existing Form to a Solution
Figure : Completed splash screen 3
4
Adding an Existing Form to a Solution
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 tmrExit Me.Hide() tmrExit.Enabled = False frmMain.ShowDialog() Me.Close() Syntax used to instruct the computer to create an object from a class: Dim variablename As New classname , e.g., to create a form Dim mForm As New frmMain Otherwise, the form frmMain will show up many times. The name of the main form in Harvey Industries Solution 4
5
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.picCountry.Image = …… as a comment Click Splash Form’s PictureBox picCountry Use the task box of the PictureBox to set up its image file (image file is in the Resources folder of the Chap07/Splash Solution ) 5
6
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: Right click on the project in the Project Explorer Window to open the Properties Window Click the Application tab in Properties Window Click the Startup object ComboBox to set up the startup form → choose frmSplash 6
7
ShowDialog() vs. Show() Method
A form object’s ShowDialog() method allows you to display the form object on the screen with focus transfer (dialog-style interaction) The syntax is: form.ShowDialog() 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
8
Show Another Form by a Button
Download Chap07/Playtime Solution, Chap07/Harvey Industries Solution How to use a button to open a new form Project->加入現有項目->Find Playtime Form.vb to add Include Image File for the PictureBox PictureBox1 Add following codes in the Click event of a button Show Playtime on the Harvey Industries’ MainForm Me.Hide() frmPlaytime.ShowDialog() Me.txtName.Text = frmPlaytime. txtName.Text Me.Show() frmPlaytime.Show() or .ShowDialog() ‘Show 2 forms frmPlaytime.Focus() (when using frmPlaytime.Show() ) The name of main form in Playtime Solution Value passing between two forms 8 8
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.