NS Basic/Desktop Tutorial #2:

A program with multiple Forms


© NS BASIC Corporation. All rights reserved.

Purpose

The purpose of this tutorial is to help learn a few more NS Basic/Desktop programming techniques. You should complete Tutorial #1 before beginning this tutorial. In this tutorial, the techniques of using multiple forms will be covered.

Description of the Program

The program to be developed has two forms. Form #1 allows the user to enter a birthdate and name. Form #2 shows the values of the previously entered birthdate and name plus it tells on what day of the week the birthdate occurred.

Program Development

1. Startup

2. Modify the First Form's Parameters

3. Create objects for Form 1

Add a TextBox to enter the user's name:

Add a CommandButton to transfer to Form 2

4. Create the Second Form

5. Create objects for Form 2

Add a Label before the birthday textbox:

Add a TextBox where the birthday will be shown:

Add a Label before the name :

Add a TextBox where the name will be shown:

Add a Label before the day-of-the-week:

Add a TextBox where the day-of-week will be shown:

Add a button to allow transfer back to form # 1:

6. Code to transfer to Form 2

When the user taps on the "Show the Day of the Week" button, we want Form 2 to appear.

	MyForm1_Hide
	MyForm2_Show

This code hides the objects on Form 1 and displays the objects on Form 2.

7. Provide Code for Form 2 Objects

Supply code to be executed after the form is drawn

	textName2.text = textName1.text
	textDate2.text = dateBirth3.text
	textDayName.text = WeekDayName(WeekDay(textDate2.text))

This code fills in form's TextBoxes with values before the device displays the form to the user.

8. Supply code for the Go Back button to go back to Form 1

	MyForm2_Hide
	MyForm1_Show

When this button is selected, the program will just cause Form 1 to re-appear and the user can try another date.

Save the project as Tutorial2 in a directory you like.  All form definitions, form objects, all code, and other project info are saved into the one project file.

12. Generate and test the executable file

If you have any errors, an error message will appear and the code window will appear with the section of code where the error occurred highlighted. Errors must be corrected and run repeated until there are no more errors.

Congratulations !! You have now written your second NS Basic/Desktop program.