<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.appstudio.dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Debinbrier</id>
	<title>NSB App Studio - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.appstudio.dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Debinbrier"/>
	<link rel="alternate" type="text/html" href="https://wiki.appstudio.dev/Special:Contributions/Debinbrier"/>
	<updated>2026-10-16T14:26:27Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.46.1</generator>
	<entry>
		<id>https://wiki.appstudio.dev/index.php?title=Multiple_Forms&amp;diff=8864</id>
		<title>Multiple Forms</title>
		<link rel="alternate" type="text/html" href="https://wiki.appstudio.dev/index.php?title=Multiple_Forms&amp;diff=8864"/>
		<updated>2016-12-02T20:33:21Z</updated>

		<summary type="html">&lt;p&gt;Debinbrier: /* Create Objects for Form 1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Purpose ==&lt;br /&gt;
&lt;br /&gt;
The purpose of this tutorial is to help learn a few more NS Basic/App Studio programming techniques. You should complete Tutorial #1 before beginning this tutorial. In this tutorial, the techniques of using multiple forms and Select controls will be covered.&lt;br /&gt;
&lt;br /&gt;
=== Description of the Program ===&lt;br /&gt;
&lt;br /&gt;
The program to be developed has two forms. Form #1 allows the user to enter a birth date and name. Form #2 shows the values of the previously entered birth date and name plus it tells on what day of the week the birth date occurred. There is a Title Bar and a button on each form that will switch between forms.&lt;br /&gt;
&lt;br /&gt;
== Program Development ==&lt;br /&gt;
&lt;br /&gt;
=== Startup ===&lt;br /&gt;
&lt;br /&gt;
# Start AppStudio from the Start menu.&lt;br /&gt;
# At the initial screen select New Project dialog box, with the following settings:&lt;br /&gt;
# Form factor should be iPhone/iPad/Nexus.&lt;br /&gt;
# Language is BASIC.&lt;br /&gt;
&lt;br /&gt;
[[File:TT01.03.JPG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create Objects for Form 1 ===&lt;br /&gt;
&lt;br /&gt;
# Add a Title Bar (HeaderBar located under Jquery Mobile) for form1. In the properties window, set the leftButtonPos to &amp;quot;none&amp;quot;, the leftButtonName to blank and change rightButtonName to &amp;quot;Next&amp;quot;. Change the title to &amp;quot;Page 1&amp;quot; and put Form2 in changeform.&lt;br /&gt;
# Drag a label to the desired location and make it wider.&lt;br /&gt;
# Set its textContent in the Properties window to &amp;quot;Please Enter Your Name&amp;quot;.&lt;br /&gt;
# Add a TextBox. It should name itself TextBox1. In this tutorial, we rename it to Text1.&lt;br /&gt;
# Add 4 more labels with textContent of &amp;quot;Enter Your Birthday&amp;quot;,&amp;quot;Select Month&amp;quot;,&amp;quot;Select Day&amp;quot; and &amp;quot;Select Year&amp;quot;. There are some prettier date pickers we could have used, but we would learn less...&lt;br /&gt;
# Add 3 Select controls, drag into position and resize.&lt;br /&gt;
# Finally add a Button to the form. Resize and change the value property to read &amp;quot;Show Day of The Week&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Form 1 should now look like this:&lt;br /&gt;
&lt;br /&gt;
[[File:TT02.02.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add a new form ===&lt;br /&gt;
&lt;br /&gt;
On the IDE menu select &amp;quot;Project&amp;quot; followed by &amp;quot;Add Form&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Create Objects for Form 2 ===&lt;br /&gt;
&lt;br /&gt;
# Add a Title Bar (HeaderBar) for form2. In the Properties Window set the rightButtonIconPos to &amp;quot;none&amp;quot;, the rightButtonName to blank and change leftButtonName to &amp;quot;Prev&amp;quot;. Set the Title to Page 2. Set leftChangeForm to Form1.&lt;br /&gt;
# Add 3 labels, drag into position and resize.&lt;br /&gt;
# In the properties for each label change the Text property to &amp;quot;Welcome&amp;quot;, &amp;quot;Your Birthday is&amp;quot; and &amp;quot;Your Birthday is on&amp;quot;.&lt;br /&gt;
# Now add 3 Text boxes and drag into position.&lt;br /&gt;
# Lastly add a Button. Resize and change the value to read &amp;quot;Return to previous Page&amp;quot;. Set changeform to Form1.&lt;br /&gt;
&lt;br /&gt;
Form 2 should look like this:&lt;br /&gt;
[[File:TT02.03.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We have completed the visual design of our program so now it&#039;s time to add code to make it do something.&lt;br /&gt;
&lt;br /&gt;
We can actually run the program now. Choose Run...Start in Desktop Browser.&lt;br /&gt;
It runs in your default browser: we recommend using Chrome or Safari, as these support the WebKit extensions which mobile devices use.&lt;br /&gt;
We could even run this on a device, but let&#039;s do a bit more first...&lt;br /&gt;
&lt;br /&gt;
=== Add code to Form 1 ===&lt;br /&gt;
&lt;br /&gt;
Open the code window for Form1 from the Project Explorer window and enter the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&#039; Form1 Code &lt;br /&gt;
Dim birthday, dayofweek&lt;br /&gt;
Dim a,b,c&lt;br /&gt;
&lt;br /&gt;
Sub Main()&lt;br /&gt;
  Select1.clear()&lt;br /&gt;
  For i=0 To 11&lt;br /&gt;
    Select1.addItem(i+1)&lt;br /&gt;
  Next&lt;br /&gt;
  Select2.clear()&lt;br /&gt;
  For i=0 To 30&lt;br /&gt;
    Select2.addItem(i+1)&lt;br /&gt;
  Next&lt;br /&gt;
  Select3.clear()&lt;br /&gt;
  For i=0 To 110&lt;br /&gt;
    Select3.addItem(i+1900)&lt;br /&gt;
  Next&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The 3 Select control loops above set up the Months 1 to 12, the Days 1 to 31 and the Years 1900 to 2010.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&#039; Check to see if Select has recieved an input&lt;br /&gt;
&#039; Select (combo box) for month &lt;br /&gt;
Function Select1_onchange()&lt;br /&gt;
  a=Select1.selectedItem() &lt;br /&gt;
  &#039;MsgBox &amp;quot;selectedIndex is &amp;quot; &amp;amp; Select1.selectedIndex() &amp;amp; &amp;quot; with value &amp;quot; &amp;amp; a &lt;br /&gt;
End Function&lt;br /&gt;
&lt;br /&gt;
Function Select2_onchange()&lt;br /&gt;
 &#039; Select (combo box) for day &lt;br /&gt;
  b=Select2.selectedItem()&lt;br /&gt;
  &#039;MsgBox &amp;quot;selectedIndex is &amp;quot; &amp;amp; Select2.selectedIndex() &amp;amp; &amp;quot; with value &amp;quot; &amp;amp; b&lt;br /&gt;
End Function&lt;br /&gt;
&lt;br /&gt;
Function Select3_onchange()&lt;br /&gt;
  &#039; Select (combo box) for year &lt;br /&gt;
  c=Select3.selectedItem()&lt;br /&gt;
  &#039;MsgBox &amp;quot;selectedIndex is &amp;quot; &amp;amp; Select3.selectedIndex() &amp;amp; &amp;quot; with value &amp;quot; &amp;amp; c &lt;br /&gt;
End Function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The three above functions assign the selections from the ComboBoxes to three variables a, b and c.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Function Button1_onclick()&lt;br /&gt;
  birthday = a &amp;amp; &amp;quot;/ &amp;quot; &amp;amp; b &amp;amp; &amp;quot;/ &amp;quot; &amp;amp; c &lt;br /&gt;
  &#039;MsgBox &amp;quot;Birthday = &amp;quot; &amp;amp; birthday &lt;br /&gt;
  TextBox1.value = Text1.value&lt;br /&gt;
  TextBox2.value = birthday&lt;br /&gt;
  dayofweek = Weekday(birthday) &lt;br /&gt;
  &#039;MsgBox &amp;quot;Day of Week = &amp;quot; &amp;amp; dayofweek &lt;br /&gt;
  TextBox3.value = WeekdayName (dayofweek)&lt;br /&gt;
  ChangeForm(Form2)&lt;br /&gt;
End Function&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When Button1 is clicked, the following happens.&lt;br /&gt;
&lt;br /&gt;
* The values of a, b and c are concatenated together with &amp;quot;/ &amp;quot; to form MM/ DD/ YYYY which is assigned to birthday.&lt;br /&gt;
* The internal WeekDay function is called and the Weekday value is assigned to dayofweek.&lt;br /&gt;
* The internal WeekdayName function is called and the WeekDayName value is assisgned to Text4 which will appear on the form2.&lt;br /&gt;
* Form1 is hidden and Form2 appears.&lt;br /&gt;
&lt;br /&gt;
=== Save the project ===&lt;br /&gt;
&lt;br /&gt;
From the IDE menu select &amp;quot;File&amp;quot; then &amp;quot;Save Project&amp;quot; or &amp;quot;Ctrl S&amp;quot; or the Save Icon from the Tool Bar.&lt;br /&gt;
&lt;br /&gt;
=== Run the program ===&lt;br /&gt;
&lt;br /&gt;
We can run the program again. Choose Run...Start in Desktop Browser.&lt;br /&gt;
If all goes well the forms should appear similar to those shown below.&lt;br /&gt;
&lt;br /&gt;
[[File:TT02.04.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Deploy the App ===&lt;br /&gt;
&lt;br /&gt;
Congratulations...&lt;br /&gt;
The only thing left to do is deploy the program.&lt;/div&gt;</summary>
		<author><name>Debinbrier</name></author>
	</entry>
	<entry>
		<id>https://wiki.appstudio.dev/index.php?title=Adding_Two_Numbers&amp;diff=8831</id>
		<title>Adding Two Numbers</title>
		<link rel="alternate" type="text/html" href="https://wiki.appstudio.dev/index.php?title=Adding_Two_Numbers&amp;diff=8831"/>
		<updated>2016-11-22T16:08:47Z</updated>

		<summary type="html">&lt;p&gt;Debinbrier: /* Error Checking */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The purpose of this tutorial is to demonstrate simply adding two numbers together using App Studio. You should have completed Tutorial #1 before beginning this tutorial.&lt;br /&gt;
&lt;br /&gt;
The program to be developed will start out adding two numbers and displaying the answer in a message box. After that we will create a program that allows the user to enter the two numbers on a form and display the answer when the Add button is clicked.&lt;br /&gt;
&lt;br /&gt;
== Getting Started ==&lt;br /&gt;
&lt;br /&gt;
* Start AppStudio from the Start menu.&lt;br /&gt;
* At the initial screen select New Project dialog box, with the following settings:&lt;br /&gt;
*# Form factor should be iPhone/iPad/Nexus&lt;br /&gt;
*# Language is BASIC&lt;br /&gt;
*# Then click on Code at the top of the Project Explorer window on the right. This will open a code window.&lt;br /&gt;
&lt;br /&gt;
The form and the code below Form1 won&#039;t be used in this example.&lt;br /&gt;
&lt;br /&gt;
[[File:TT01.03.JPG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Adding Two Numbers Using MsgBox == &lt;br /&gt;
&lt;br /&gt;
To demonstrate how simple it is to create a program to add two numbers together, we will enter code to add two numbers and display the answer in a MsgBox.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Code ===&lt;br /&gt;
&lt;br /&gt;
First we declare three variables to hold our values:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;FirstNumber&#039;&#039;, contains the first half of our math equation&lt;br /&gt;
* &#039;&#039;SecondNumber&#039;&#039;, contains the second half of our math equation&lt;br /&gt;
* &#039;&#039;Total&#039;&#039;, contains the answer&lt;br /&gt;
&lt;br /&gt;
Next we set &#039;&#039;FirstNumber&#039;&#039; to equal 10 and &#039;&#039;SecondNumber&#039;&#039; to 7.&lt;br /&gt;
&lt;br /&gt;
We then add the two numbers and store the result in &#039;&#039;Total&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, we display the result in a MsgBox.&lt;br /&gt;
&lt;br /&gt;
Your code should look like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Sub Main&lt;br /&gt;
   Dim FirstNumber&lt;br /&gt;
   Dim SecondNumber&lt;br /&gt;
   Dim Total&lt;br /&gt;
   &lt;br /&gt;
   FirstNumber = 10&lt;br /&gt;
   SecondNumber = 7&lt;br /&gt;
   &lt;br /&gt;
   Total = FirstNumber + SecondNumber&lt;br /&gt;
      &lt;br /&gt;
   MsgBox &amp;quot;And the total is: &amp;quot; &amp;amp; Total&lt;br /&gt;
   &lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.2.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving the Project ===&lt;br /&gt;
&lt;br /&gt;
Save the project by selecting File from the top menu and select Save Project, or click on the disk symbol in the toolbar.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Program ===&lt;br /&gt;
&lt;br /&gt;
Select Start in Desktop Browser from the Run menu (or press F5, or click on the Start in Desktop Browser button in the toolbar).&lt;br /&gt;
&lt;br /&gt;
 [[File:TT03.3a.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
If you deploy this program to an iPhone, it will look like this:&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.3b.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: You can make the MsgBox look better by using NSB.MsgBox.&lt;br /&gt;
&lt;br /&gt;
== Adding Two Numbers Using a Form ==&lt;br /&gt;
&lt;br /&gt;
Displaying the total of two fixed numbers in a MessageBox is not very practical since you need to modify the program every time you want to change the numbers. We will create a new version of the program that will allow the user to enter the numbers on a form and display the total when the user clicks a button.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Form ===&lt;br /&gt;
&lt;br /&gt;
Start App Studio from the Start menu. It will open the program you entered previously, Add2MsgBox.nsx. Select File and New Project, save it under the name Add2Form.nsx.&lt;br /&gt;
&lt;br /&gt;
Add a text box for entering the first number.&lt;br /&gt;
* Click on the TextBox object in the Toolbox (&amp;quot;Tb&amp;quot; icon). This is located under JQuery Mobile.  This creates a new TextBox near the top left corner of the form, surrounded by a red border.&lt;br /&gt;
* In the Properties window, change the id to &amp;quot;txtFirstNo&amp;quot;.&lt;br /&gt;
* In the Properties window change the inputType to number.&lt;br /&gt;
* Use the mouse to change the size of the TextBox and reposition it on the form.&lt;br /&gt;
* Add a text label before the first number:&lt;br /&gt;
&lt;br /&gt;
Click on the label object in the Toolbox (&amp;quot;Lb&amp;quot; icon). This is located under Common. A new label object will show in the top left corner of the form.&lt;br /&gt;
* Move it on the form before the text box. It should remain selected, shown by the red border; if not click on it to select.&lt;br /&gt;
* In the Properties window, change the id to &amp;quot;lblFirstNo&amp;quot; (This is optional since we will not need to refer to it in our program.)&lt;br /&gt;
* In the Properties window, change the text to &amp;quot;First Number&amp;quot;. Adjust the size of the label so that the text displays in 1 row.&lt;br /&gt;
* Add a text box for entering the second number:&lt;br /&gt;
&lt;br /&gt;
Drag a TextBox object from the ToolBox to the Design Screen.&lt;br /&gt;
* In the Properties window, change the id to &amp;quot;txtSecondNo&amp;quot;.&lt;br /&gt;
* In the Properties window change the inputType to number.&lt;br /&gt;
* Use the mouse to change the size of the TextBox and reposition it on the form.&lt;br /&gt;
* Add a text label before the second number:&lt;br /&gt;
&lt;br /&gt;
Drag a Label object from the ToolBox to the Design Screen. &lt;br /&gt;
* Place it on the form before the text box. It should remain selected, shown by the red border; if not click on it to select.&lt;br /&gt;
* In the Properties window, change the Name to &amp;quot;lblSecondNo&amp;quot; (This is optional since we will not need to refer to it in our program.)&lt;br /&gt;
* In the Properties window, change the text to &amp;quot;Second Number&amp;quot;. Adjust the size of the label so that the text displays in 1 row.&lt;br /&gt;
* Add a text box for displaying the Total:&lt;br /&gt;
&lt;br /&gt;
Drag a TextBox object from the ToolBox to the Design Screen.&lt;br /&gt;
* In the Properties window, change the id to &amp;quot;txtTotal&amp;quot;.&lt;br /&gt;
* Scroll down in the Properties Window and change the value of readonly in the drop down box to readonly=&amp;quot;readonly&amp;quot; (sets the readOnly property of the field to truemaking it read-only)&lt;br /&gt;
* In the Properties Window delete the value of placeholder&lt;br /&gt;
* Use the mouse to expand the size of the TextBox and reposition on the form.&lt;br /&gt;
* Add a label before the Total field:&lt;br /&gt;
&lt;br /&gt;
Drag a Label object from the ToolBox to the Design Screen.&lt;br /&gt;
* Using the mouse, move it on the form before the text box and click on it to select it if it isn&#039;t selected already.&lt;br /&gt;
* In the Properties Window, change the id to &amp;quot;lblTotal&amp;quot; (optional)&lt;br /&gt;
* In the Properties window, change the text to &amp;quot;Total =&amp;quot;&lt;br /&gt;
* Expand the label to hold the text&lt;br /&gt;
&lt;br /&gt;
Add a button to add the two numbers:&lt;br /&gt;
* Drag a Button object from the ToolBox to the Design Screen.&lt;br /&gt;
* In the Properties window, change the id to &amp;quot;cmdAdd&amp;quot;.&lt;br /&gt;
* In the Properties window, change the value to &amp;quot;Add&amp;quot;. This is the text that&#039;s shown on the button.&lt;br /&gt;
* Use the mouse to expand the size of the CommandButton to display the text all on the same line and reposition on the form.&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.4.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving the Project ===&lt;br /&gt;
&lt;br /&gt;
Save the project by selecting File from the top main and select Save Project.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Form ===&lt;br /&gt;
&lt;br /&gt;
At this point we have a finished form but have not entered any code to actually add the numbers and display the results. You can run the program to see how the form will appear on a device or in the browser. You may find that some tweaks are needed in the size and position of some of the controls and labels.&lt;br /&gt;
&lt;br /&gt;
* Select Start in Desktop Browser from the Run menu, or click on the Start in Desktop Browser button, the rightmost symbol in the toolbar.&lt;br /&gt;
* As a shortcut, you can use F5 to Start the program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.5.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating the Code ===&lt;br /&gt;
&lt;br /&gt;
We are now ready to add code to our form to make it actually do some work. We will use the same variables we declared in our first example but read their values from the fields entered by the user. Reading the user&#039;s input and adding the numbers will be performed when the user clicks on the Add button.&lt;br /&gt;
&lt;br /&gt;
App Studio will automatically open the Code Window and generate the Add button subroutine when you select the Events drop down box in the properties window of the button and choose &#039;onclick&#039;. You can also open the Code Window by clicking on Code under Form1 in the Project Explorer.&lt;br /&gt;
&lt;br /&gt;
Enter the code so it looks like the following screen.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Sub cmdAdd_onclick() &lt;br /&gt;
  Dim FirstNumber&lt;br /&gt;
  Dim SecondNumber&lt;br /&gt;
  Dim Total&lt;br /&gt;
&lt;br /&gt;
  FirstNumber  = Number(txtFirstNo.value)&lt;br /&gt;
  SecondNumber = Number(txtSecondNo.value)&lt;br /&gt;
  Total = FirstNumber + SecondNumber&lt;br /&gt;
&lt;br /&gt;
  txtTotal.value = Total&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.6.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
The Number function is used to convert the string the user enters into a number.&lt;br /&gt;
&lt;br /&gt;
Note: The code uses variables to hold the user&#039;s numbers and the total. You could also eliminate all the variables by directly accessing the fields and not storing anything.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
txtTotal.value = Number(txtFirstNo.value) + Number(txtSecondNo.value)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Either way works but I feel the program is easier to understand when the variables are used.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Program ===&lt;br /&gt;
&lt;br /&gt;
Select Start in Desktop Browser from the Run menu (or press F5).&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.7.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
There are three TextBox fields on the form. The first two accept user input and the third (Total) has its readonly property set to readonly, making it a read-only field. This property can be set in the Property window.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Error Checking ===&lt;br /&gt;
&lt;br /&gt;
The above program is very simple in terms of its function and lack of any type of error checking. As an additional exercise, code was added to verify that the user has entered the proper values when the Add button is clicked. The IsNumeric function is used to verify that the user has entered a proper number into both text box fields. An error message is displayed if the field is left blank or does not contain a valid number. Setting the textbox type to number switches the keyboard to numbers initially, but it is possible to switch it to letter input! Or the user might be using an external keyboard, which would also allow him to enter letters into the numeric fields.&lt;br /&gt;
&lt;br /&gt;
The final program with error checking:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pre&amp;gt;&lt;br /&gt;
Sub cmdAdd_onClick()&lt;br /&gt;
   Dim FirstNumber&lt;br /&gt;
   Dim SecondNumber&lt;br /&gt;
   Dim Total&lt;br /&gt;
&lt;br /&gt;
   If Not IsNumeric(txtFirstNo.value) or txtFirstNo.value=&amp;quot;&amp;quot; Then&lt;br /&gt;
      MsgBox &amp;quot;First Number must be a number!&amp;quot;,0&lt;br /&gt;
      Exit Sub&lt;br /&gt;
   End If&lt;br /&gt;
&lt;br /&gt;
   If Not IsNumeric(txtSecondNo.value)  or txtSecondNo.value=&amp;quot;&amp;quot; Then&lt;br /&gt;
      MsgBox &amp;quot;Second Number must be a number!&amp;quot;,0&lt;br /&gt;
      Exit Sub&lt;br /&gt;
   End If&lt;br /&gt;
         &lt;br /&gt;
   FirstNumber  = Number(txtFirstNo.value)&lt;br /&gt;
   SecondNumber = Number(txtSecondNo.value)&lt;br /&gt;
   &lt;br /&gt;
   Total = FirstNumber + SecondNumber&lt;br /&gt;
   &lt;br /&gt;
   txtTotal.value = Total&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.8.png]]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Debinbrier</name></author>
	</entry>
	<entry>
		<id>https://wiki.appstudio.dev/index.php?title=Adding_Two_Numbers&amp;diff=8830</id>
		<title>Adding Two Numbers</title>
		<link rel="alternate" type="text/html" href="https://wiki.appstudio.dev/index.php?title=Adding_Two_Numbers&amp;diff=8830"/>
		<updated>2016-11-22T16:06:21Z</updated>

		<summary type="html">&lt;p&gt;Debinbrier: /* Creating the Form */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The purpose of this tutorial is to demonstrate simply adding two numbers together using App Studio. You should have completed Tutorial #1 before beginning this tutorial.&lt;br /&gt;
&lt;br /&gt;
The program to be developed will start out adding two numbers and displaying the answer in a message box. After that we will create a program that allows the user to enter the two numbers on a form and display the answer when the Add button is clicked.&lt;br /&gt;
&lt;br /&gt;
== Getting Started ==&lt;br /&gt;
&lt;br /&gt;
* Start AppStudio from the Start menu.&lt;br /&gt;
* At the initial screen select New Project dialog box, with the following settings:&lt;br /&gt;
*# Form factor should be iPhone/iPad/Nexus&lt;br /&gt;
*# Language is BASIC&lt;br /&gt;
*# Then click on Code at the top of the Project Explorer window on the right. This will open a code window.&lt;br /&gt;
&lt;br /&gt;
The form and the code below Form1 won&#039;t be used in this example.&lt;br /&gt;
&lt;br /&gt;
[[File:TT01.03.JPG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Adding Two Numbers Using MsgBox == &lt;br /&gt;
&lt;br /&gt;
To demonstrate how simple it is to create a program to add two numbers together, we will enter code to add two numbers and display the answer in a MsgBox.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Code ===&lt;br /&gt;
&lt;br /&gt;
First we declare three variables to hold our values:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;FirstNumber&#039;&#039;, contains the first half of our math equation&lt;br /&gt;
* &#039;&#039;SecondNumber&#039;&#039;, contains the second half of our math equation&lt;br /&gt;
* &#039;&#039;Total&#039;&#039;, contains the answer&lt;br /&gt;
&lt;br /&gt;
Next we set &#039;&#039;FirstNumber&#039;&#039; to equal 10 and &#039;&#039;SecondNumber&#039;&#039; to 7.&lt;br /&gt;
&lt;br /&gt;
We then add the two numbers and store the result in &#039;&#039;Total&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, we display the result in a MsgBox.&lt;br /&gt;
&lt;br /&gt;
Your code should look like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Sub Main&lt;br /&gt;
   Dim FirstNumber&lt;br /&gt;
   Dim SecondNumber&lt;br /&gt;
   Dim Total&lt;br /&gt;
   &lt;br /&gt;
   FirstNumber = 10&lt;br /&gt;
   SecondNumber = 7&lt;br /&gt;
   &lt;br /&gt;
   Total = FirstNumber + SecondNumber&lt;br /&gt;
      &lt;br /&gt;
   MsgBox &amp;quot;And the total is: &amp;quot; &amp;amp; Total&lt;br /&gt;
   &lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.2.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving the Project ===&lt;br /&gt;
&lt;br /&gt;
Save the project by selecting File from the top menu and select Save Project, or click on the disk symbol in the toolbar.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Program ===&lt;br /&gt;
&lt;br /&gt;
Select Start in Desktop Browser from the Run menu (or press F5, or click on the Start in Desktop Browser button in the toolbar).&lt;br /&gt;
&lt;br /&gt;
 [[File:TT03.3a.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
If you deploy this program to an iPhone, it will look like this:&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.3b.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: You can make the MsgBox look better by using NSB.MsgBox.&lt;br /&gt;
&lt;br /&gt;
== Adding Two Numbers Using a Form ==&lt;br /&gt;
&lt;br /&gt;
Displaying the total of two fixed numbers in a MessageBox is not very practical since you need to modify the program every time you want to change the numbers. We will create a new version of the program that will allow the user to enter the numbers on a form and display the total when the user clicks a button.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Form ===&lt;br /&gt;
&lt;br /&gt;
Start App Studio from the Start menu. It will open the program you entered previously, Add2MsgBox.nsx. Select File and New Project, save it under the name Add2Form.nsx.&lt;br /&gt;
&lt;br /&gt;
Add a text box for entering the first number.&lt;br /&gt;
* Click on the TextBox object in the Toolbox (&amp;quot;Tb&amp;quot; icon). This is located under JQuery Mobile.  This creates a new TextBox near the top left corner of the form, surrounded by a red border.&lt;br /&gt;
* In the Properties window, change the id to &amp;quot;txtFirstNo&amp;quot;.&lt;br /&gt;
* In the Properties window change the inputType to number.&lt;br /&gt;
* Use the mouse to change the size of the TextBox and reposition it on the form.&lt;br /&gt;
* Add a text label before the first number:&lt;br /&gt;
&lt;br /&gt;
Click on the label object in the Toolbox (&amp;quot;Lb&amp;quot; icon). This is located under Common. A new label object will show in the top left corner of the form.&lt;br /&gt;
* Move it on the form before the text box. It should remain selected, shown by the red border; if not click on it to select.&lt;br /&gt;
* In the Properties window, change the id to &amp;quot;lblFirstNo&amp;quot; (This is optional since we will not need to refer to it in our program.)&lt;br /&gt;
* In the Properties window, change the text to &amp;quot;First Number&amp;quot;. Adjust the size of the label so that the text displays in 1 row.&lt;br /&gt;
* Add a text box for entering the second number:&lt;br /&gt;
&lt;br /&gt;
Drag a TextBox object from the ToolBox to the Design Screen.&lt;br /&gt;
* In the Properties window, change the id to &amp;quot;txtSecondNo&amp;quot;.&lt;br /&gt;
* In the Properties window change the inputType to number.&lt;br /&gt;
* Use the mouse to change the size of the TextBox and reposition it on the form.&lt;br /&gt;
* Add a text label before the second number:&lt;br /&gt;
&lt;br /&gt;
Drag a Label object from the ToolBox to the Design Screen. &lt;br /&gt;
* Place it on the form before the text box. It should remain selected, shown by the red border; if not click on it to select.&lt;br /&gt;
* In the Properties window, change the Name to &amp;quot;lblSecondNo&amp;quot; (This is optional since we will not need to refer to it in our program.)&lt;br /&gt;
* In the Properties window, change the text to &amp;quot;Second Number&amp;quot;. Adjust the size of the label so that the text displays in 1 row.&lt;br /&gt;
* Add a text box for displaying the Total:&lt;br /&gt;
&lt;br /&gt;
Drag a TextBox object from the ToolBox to the Design Screen.&lt;br /&gt;
* In the Properties window, change the id to &amp;quot;txtTotal&amp;quot;.&lt;br /&gt;
* Scroll down in the Properties Window and change the value of readonly in the drop down box to readonly=&amp;quot;readonly&amp;quot; (sets the readOnly property of the field to truemaking it read-only)&lt;br /&gt;
* In the Properties Window delete the value of placeholder&lt;br /&gt;
* Use the mouse to expand the size of the TextBox and reposition on the form.&lt;br /&gt;
* Add a label before the Total field:&lt;br /&gt;
&lt;br /&gt;
Drag a Label object from the ToolBox to the Design Screen.&lt;br /&gt;
* Using the mouse, move it on the form before the text box and click on it to select it if it isn&#039;t selected already.&lt;br /&gt;
* In the Properties Window, change the id to &amp;quot;lblTotal&amp;quot; (optional)&lt;br /&gt;
* In the Properties window, change the text to &amp;quot;Total =&amp;quot;&lt;br /&gt;
* Expand the label to hold the text&lt;br /&gt;
&lt;br /&gt;
Add a button to add the two numbers:&lt;br /&gt;
* Drag a Button object from the ToolBox to the Design Screen.&lt;br /&gt;
* In the Properties window, change the id to &amp;quot;cmdAdd&amp;quot;.&lt;br /&gt;
* In the Properties window, change the value to &amp;quot;Add&amp;quot;. This is the text that&#039;s shown on the button.&lt;br /&gt;
* Use the mouse to expand the size of the CommandButton to display the text all on the same line and reposition on the form.&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.4.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving the Project ===&lt;br /&gt;
&lt;br /&gt;
Save the project by selecting File from the top main and select Save Project.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Form ===&lt;br /&gt;
&lt;br /&gt;
At this point we have a finished form but have not entered any code to actually add the numbers and display the results. You can run the program to see how the form will appear on a device or in the browser. You may find that some tweaks are needed in the size and position of some of the controls and labels.&lt;br /&gt;
&lt;br /&gt;
* Select Start in Desktop Browser from the Run menu, or click on the Start in Desktop Browser button, the rightmost symbol in the toolbar.&lt;br /&gt;
* As a shortcut, you can use F5 to Start the program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.5.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating the Code ===&lt;br /&gt;
&lt;br /&gt;
We are now ready to add code to our form to make it actually do some work. We will use the same variables we declared in our first example but read their values from the fields entered by the user. Reading the user&#039;s input and adding the numbers will be performed when the user clicks on the Add button.&lt;br /&gt;
&lt;br /&gt;
App Studio will automatically open the Code Window and generate the Add button subroutine when you select the Events drop down box in the properties window of the button and choose &#039;onclick&#039;. You can also open the Code Window by clicking on Code under Form1 in the Project Explorer.&lt;br /&gt;
&lt;br /&gt;
Enter the code so it looks like the following screen.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Sub cmdAdd_onclick() &lt;br /&gt;
  Dim FirstNumber&lt;br /&gt;
  Dim SecondNumber&lt;br /&gt;
  Dim Total&lt;br /&gt;
&lt;br /&gt;
  FirstNumber  = Number(txtFirstNo.value)&lt;br /&gt;
  SecondNumber = Number(txtSecondNo.value)&lt;br /&gt;
  Total = FirstNumber + SecondNumber&lt;br /&gt;
&lt;br /&gt;
  txtTotal.value = Total&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.6.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
The Number function is used to convert the string the user enters into a number.&lt;br /&gt;
&lt;br /&gt;
Note: The code uses variables to hold the user&#039;s numbers and the total. You could also eliminate all the variables by directly accessing the fields and not storing anything.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
txtTotal.value = Number(txtFirstNo.value) + Number(txtSecondNo.value)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Either way works but I feel the program is easier to understand when the variables are used.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Program ===&lt;br /&gt;
&lt;br /&gt;
Select Start in Desktop Browser from the Run menu (or press F5).&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.7.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
There are three TextBox fields on the form. The first two accept user input and the third (Total) has its readonly property set to readonly, making it a read-only field. This property can be set in the Property window.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Error Checking ===&lt;br /&gt;
&lt;br /&gt;
The above program is very simple in terms of its function and lack of any type of error checking. As an additional exercise, code was added to verify that the user has entered the proper values when the Add button is clicked. The IsNumeric function is used to verify that the user has entered a proper number into both text box fields. An error message is displayed if the field is left blank or does not contain a valid number. Setting the textbox type to number switches the keyboard to numbers initially, but it is possible to switch it to letter input! Or the user might be using an external keyboard, which would also allow him to enter letters into the numeric fields.&lt;br /&gt;
&lt;br /&gt;
The final program with error checking:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pre&amp;gt;&lt;br /&gt;
Sub cmdAdd_onClick()&lt;br /&gt;
   Dim FirstNumber&lt;br /&gt;
   Dim SecondNumber&lt;br /&gt;
   Dim Total&lt;br /&gt;
&lt;br /&gt;
   If Not IsNumeric(txtFirstNo.value) or txtFirstNo.value=&amp;quot;&amp;quot; Then&lt;br /&gt;
      MsgBox &amp;quot;First Number must be a number!&amp;quot;,0&lt;br /&gt;
      Exit Sub&lt;br /&gt;
   End If&lt;br /&gt;
&lt;br /&gt;
   If Not IsNumeric(txtSecondNo.value) Then&lt;br /&gt;
      MsgBox &amp;quot;Second Number must be a number!&amp;quot;,0&lt;br /&gt;
      Exit Sub&lt;br /&gt;
   End If&lt;br /&gt;
         &lt;br /&gt;
   FirstNumber  = Number(txtFirstNo.value)&lt;br /&gt;
   SecondNumber = Number(txtSecondNo.value)&lt;br /&gt;
   &lt;br /&gt;
   Total = FirstNumber + SecondNumber&lt;br /&gt;
   &lt;br /&gt;
   txtTotal.value = Total&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.8.png]]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Debinbrier</name></author>
	</entry>
	<entry>
		<id>https://wiki.appstudio.dev/index.php?title=Adding_Two_Numbers&amp;diff=8829</id>
		<title>Adding Two Numbers</title>
		<link rel="alternate" type="text/html" href="https://wiki.appstudio.dev/index.php?title=Adding_Two_Numbers&amp;diff=8829"/>
		<updated>2016-11-22T16:05:17Z</updated>

		<summary type="html">&lt;p&gt;Debinbrier: /* Creating the Form */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The purpose of this tutorial is to demonstrate simply adding two numbers together using App Studio. You should have completed Tutorial #1 before beginning this tutorial.&lt;br /&gt;
&lt;br /&gt;
The program to be developed will start out adding two numbers and displaying the answer in a message box. After that we will create a program that allows the user to enter the two numbers on a form and display the answer when the Add button is clicked.&lt;br /&gt;
&lt;br /&gt;
== Getting Started ==&lt;br /&gt;
&lt;br /&gt;
* Start AppStudio from the Start menu.&lt;br /&gt;
* At the initial screen select New Project dialog box, with the following settings:&lt;br /&gt;
*# Form factor should be iPhone/iPad/Nexus&lt;br /&gt;
*# Language is BASIC&lt;br /&gt;
*# Then click on Code at the top of the Project Explorer window on the right. This will open a code window.&lt;br /&gt;
&lt;br /&gt;
The form and the code below Form1 won&#039;t be used in this example.&lt;br /&gt;
&lt;br /&gt;
[[File:TT01.03.JPG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Adding Two Numbers Using MsgBox == &lt;br /&gt;
&lt;br /&gt;
To demonstrate how simple it is to create a program to add two numbers together, we will enter code to add two numbers and display the answer in a MsgBox.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Code ===&lt;br /&gt;
&lt;br /&gt;
First we declare three variables to hold our values:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;FirstNumber&#039;&#039;, contains the first half of our math equation&lt;br /&gt;
* &#039;&#039;SecondNumber&#039;&#039;, contains the second half of our math equation&lt;br /&gt;
* &#039;&#039;Total&#039;&#039;, contains the answer&lt;br /&gt;
&lt;br /&gt;
Next we set &#039;&#039;FirstNumber&#039;&#039; to equal 10 and &#039;&#039;SecondNumber&#039;&#039; to 7.&lt;br /&gt;
&lt;br /&gt;
We then add the two numbers and store the result in &#039;&#039;Total&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, we display the result in a MsgBox.&lt;br /&gt;
&lt;br /&gt;
Your code should look like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Sub Main&lt;br /&gt;
   Dim FirstNumber&lt;br /&gt;
   Dim SecondNumber&lt;br /&gt;
   Dim Total&lt;br /&gt;
   &lt;br /&gt;
   FirstNumber = 10&lt;br /&gt;
   SecondNumber = 7&lt;br /&gt;
   &lt;br /&gt;
   Total = FirstNumber + SecondNumber&lt;br /&gt;
      &lt;br /&gt;
   MsgBox &amp;quot;And the total is: &amp;quot; &amp;amp; Total&lt;br /&gt;
   &lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.2.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving the Project ===&lt;br /&gt;
&lt;br /&gt;
Save the project by selecting File from the top menu and select Save Project, or click on the disk symbol in the toolbar.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Program ===&lt;br /&gt;
&lt;br /&gt;
Select Start in Desktop Browser from the Run menu (or press F5, or click on the Start in Desktop Browser button in the toolbar).&lt;br /&gt;
&lt;br /&gt;
 [[File:TT03.3a.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
If you deploy this program to an iPhone, it will look like this:&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.3b.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: You can make the MsgBox look better by using NSB.MsgBox.&lt;br /&gt;
&lt;br /&gt;
== Adding Two Numbers Using a Form ==&lt;br /&gt;
&lt;br /&gt;
Displaying the total of two fixed numbers in a MessageBox is not very practical since you need to modify the program every time you want to change the numbers. We will create a new version of the program that will allow the user to enter the numbers on a form and display the total when the user clicks a button.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Form ===&lt;br /&gt;
&lt;br /&gt;
Start App Studio from the Start menu. It will open the program you entered previously, Add2MsgBox.nsx. Select File and New Project, save it under the name Add2Form.nsx.&lt;br /&gt;
&lt;br /&gt;
Add a text box for entering the first number.&lt;br /&gt;
* Click on the TextBox object in the Toolbox (&amp;quot;Tb&amp;quot; icon). This is located under JQuery Mobile.  This creates a new TextBox near the top left corner of the form, surrounded by a red border.&lt;br /&gt;
* In the Properties window, change the id to &amp;quot;txtFirstNo&amp;quot;.&lt;br /&gt;
* In the Properties window change the inputType to number.&lt;br /&gt;
* Use the mouse to change the size of the TextBox and reposition it on the form.&lt;br /&gt;
* Add a text label before the first number:&lt;br /&gt;
&lt;br /&gt;
Click on the label object in the Toolbox (&amp;quot;A&amp;quot; icon). A new label object will show in the top left corner of the form.&lt;br /&gt;
* Move it on the form before the text box. It should remain selected, shown by the red border; if not click on it to select.&lt;br /&gt;
* In the Properties window, change the id to &amp;quot;lblFirstNo&amp;quot; (This is optional since we will not need to refer to it in our program.)&lt;br /&gt;
* In the Properties window, change the text to &amp;quot;First Number&amp;quot;. Adjust the size of the label so that the text displays in 1 row.&lt;br /&gt;
* Add a text box for entering the second number:&lt;br /&gt;
&lt;br /&gt;
Drag a TextBox object from the ToolBox to the Design Screen.&lt;br /&gt;
* In the Properties window, change the id to &amp;quot;txtSecondNo&amp;quot;.&lt;br /&gt;
* In the Properties window change the inputType to number.&lt;br /&gt;
* Use the mouse to change the size of the TextBox and reposition it on the form.&lt;br /&gt;
* Add a text label before the second number:&lt;br /&gt;
&lt;br /&gt;
Drag a Label object from the ToolBox to the Design Screen. This is located under Common.&lt;br /&gt;
* Place it on the form before the text box. It should remain selected, shown by the red border; if not click on it to select.&lt;br /&gt;
* In the Properties window, change the Name to &amp;quot;lblSecondNo&amp;quot; (This is optional since we will not need to refer to it in our program.)&lt;br /&gt;
* In the Properties window, change the text to &amp;quot;Second Number&amp;quot;. Adjust the size of the label so that the text displays in 1 row.&lt;br /&gt;
* Add a text box for displaying the Total:&lt;br /&gt;
&lt;br /&gt;
Drag a TextBox object from the ToolBox to the Design Screen.&lt;br /&gt;
* In the Properties window, change the id to &amp;quot;txtTotal&amp;quot;.&lt;br /&gt;
* Scroll down in the Properties Window and change the value of readonly in the drop down box to readonly=&amp;quot;readonly&amp;quot; (sets the readOnly property of the field to truemaking it read-only)&lt;br /&gt;
* In the Properties Window delete the value of placeholder&lt;br /&gt;
* Use the mouse to expand the size of the TextBox and reposition on the form.&lt;br /&gt;
* Add a label before the Total field:&lt;br /&gt;
&lt;br /&gt;
Drag a Label object from the ToolBox to the Design Screen.&lt;br /&gt;
* Using the mouse, move it on the form before the text box and click on it to select it if it isn&#039;t selected already.&lt;br /&gt;
* In the Properties Window, change the id to &amp;quot;lblTotal&amp;quot; (optional)&lt;br /&gt;
* In the Properties window, change the text to &amp;quot;Total =&amp;quot;&lt;br /&gt;
* Expand the label to hold the text&lt;br /&gt;
&lt;br /&gt;
Add a button to add the two numbers:&lt;br /&gt;
* Drag a Button object from the ToolBox to the Design Screen.&lt;br /&gt;
* In the Properties window, change the id to &amp;quot;cmdAdd&amp;quot;.&lt;br /&gt;
* In the Properties window, change the value to &amp;quot;Add&amp;quot;. This is the text that&#039;s shown on the button.&lt;br /&gt;
* Use the mouse to expand the size of the CommandButton to display the text all on the same line and reposition on the form.&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.4.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving the Project ===&lt;br /&gt;
&lt;br /&gt;
Save the project by selecting File from the top main and select Save Project.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Form ===&lt;br /&gt;
&lt;br /&gt;
At this point we have a finished form but have not entered any code to actually add the numbers and display the results. You can run the program to see how the form will appear on a device or in the browser. You may find that some tweaks are needed in the size and position of some of the controls and labels.&lt;br /&gt;
&lt;br /&gt;
* Select Start in Desktop Browser from the Run menu, or click on the Start in Desktop Browser button, the rightmost symbol in the toolbar.&lt;br /&gt;
* As a shortcut, you can use F5 to Start the program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.5.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating the Code ===&lt;br /&gt;
&lt;br /&gt;
We are now ready to add code to our form to make it actually do some work. We will use the same variables we declared in our first example but read their values from the fields entered by the user. Reading the user&#039;s input and adding the numbers will be performed when the user clicks on the Add button.&lt;br /&gt;
&lt;br /&gt;
App Studio will automatically open the Code Window and generate the Add button subroutine when you select the Events drop down box in the properties window of the button and choose &#039;onclick&#039;. You can also open the Code Window by clicking on Code under Form1 in the Project Explorer.&lt;br /&gt;
&lt;br /&gt;
Enter the code so it looks like the following screen.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Sub cmdAdd_onclick() &lt;br /&gt;
  Dim FirstNumber&lt;br /&gt;
  Dim SecondNumber&lt;br /&gt;
  Dim Total&lt;br /&gt;
&lt;br /&gt;
  FirstNumber  = Number(txtFirstNo.value)&lt;br /&gt;
  SecondNumber = Number(txtSecondNo.value)&lt;br /&gt;
  Total = FirstNumber + SecondNumber&lt;br /&gt;
&lt;br /&gt;
  txtTotal.value = Total&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.6.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
The Number function is used to convert the string the user enters into a number.&lt;br /&gt;
&lt;br /&gt;
Note: The code uses variables to hold the user&#039;s numbers and the total. You could also eliminate all the variables by directly accessing the fields and not storing anything.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
txtTotal.value = Number(txtFirstNo.value) + Number(txtSecondNo.value)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Either way works but I feel the program is easier to understand when the variables are used.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Program ===&lt;br /&gt;
&lt;br /&gt;
Select Start in Desktop Browser from the Run menu (or press F5).&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.7.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
There are three TextBox fields on the form. The first two accept user input and the third (Total) has its readonly property set to readonly, making it a read-only field. This property can be set in the Property window.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Error Checking ===&lt;br /&gt;
&lt;br /&gt;
The above program is very simple in terms of its function and lack of any type of error checking. As an additional exercise, code was added to verify that the user has entered the proper values when the Add button is clicked. The IsNumeric function is used to verify that the user has entered a proper number into both text box fields. An error message is displayed if the field is left blank or does not contain a valid number. Setting the textbox type to number switches the keyboard to numbers initially, but it is possible to switch it to letter input! Or the user might be using an external keyboard, which would also allow him to enter letters into the numeric fields.&lt;br /&gt;
&lt;br /&gt;
The final program with error checking:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pre&amp;gt;&lt;br /&gt;
Sub cmdAdd_onClick()&lt;br /&gt;
   Dim FirstNumber&lt;br /&gt;
   Dim SecondNumber&lt;br /&gt;
   Dim Total&lt;br /&gt;
&lt;br /&gt;
   If Not IsNumeric(txtFirstNo.value) or txtFirstNo.value=&amp;quot;&amp;quot; Then&lt;br /&gt;
      MsgBox &amp;quot;First Number must be a number!&amp;quot;,0&lt;br /&gt;
      Exit Sub&lt;br /&gt;
   End If&lt;br /&gt;
&lt;br /&gt;
   If Not IsNumeric(txtSecondNo.value) Then&lt;br /&gt;
      MsgBox &amp;quot;Second Number must be a number!&amp;quot;,0&lt;br /&gt;
      Exit Sub&lt;br /&gt;
   End If&lt;br /&gt;
         &lt;br /&gt;
   FirstNumber  = Number(txtFirstNo.value)&lt;br /&gt;
   SecondNumber = Number(txtSecondNo.value)&lt;br /&gt;
   &lt;br /&gt;
   Total = FirstNumber + SecondNumber&lt;br /&gt;
   &lt;br /&gt;
   txtTotal.value = Total&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:TT03.8.png]]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Debinbrier</name></author>
	</entry>
	<entry>
		<id>https://wiki.appstudio.dev/index.php?title=Multiple_Forms&amp;diff=8828</id>
		<title>Multiple Forms</title>
		<link rel="alternate" type="text/html" href="https://wiki.appstudio.dev/index.php?title=Multiple_Forms&amp;diff=8828"/>
		<updated>2016-11-22T15:55:05Z</updated>

		<summary type="html">&lt;p&gt;Debinbrier: Corrections to code for version 6.0.3&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Purpose ==&lt;br /&gt;
&lt;br /&gt;
The purpose of this tutorial is to help learn a few more NS Basic/App Studio programming techniques. You should complete Tutorial #1 before beginning this tutorial. In this tutorial, the techniques of using multiple forms and Select controls will be covered.&lt;br /&gt;
&lt;br /&gt;
=== Description of the Program ===&lt;br /&gt;
&lt;br /&gt;
The program to be developed has two forms. Form #1 allows the user to enter a birth date and name. Form #2 shows the values of the previously entered birth date and name plus it tells on what day of the week the birth date occurred. There is a Title Bar and a button on each form that will switch between forms.&lt;br /&gt;
&lt;br /&gt;
== Program Development ==&lt;br /&gt;
&lt;br /&gt;
=== Startup ===&lt;br /&gt;
&lt;br /&gt;
# Start AppStudio from the Start menu.&lt;br /&gt;
# At the initial screen select New Project dialog box, with the following settings:&lt;br /&gt;
# Form factor should be iPhone/iPad/Nexus.&lt;br /&gt;
# Language is BASIC.&lt;br /&gt;
&lt;br /&gt;
[[File:TT01.03.JPG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create Objects for Form 1 ===&lt;br /&gt;
&lt;br /&gt;
# Add a Title Bar (HeaderBar) for form1. In the properties window, set the leftButtonPos to &amp;quot;none&amp;quot;, the leftButtonName to blank and change rightButtonName to &amp;quot;Next&amp;quot;. Change the title to &amp;quot;Page 1&amp;quot; and put Form2 in changeform.&lt;br /&gt;
# Drag a label to the desired location and make it wider.&lt;br /&gt;
# Set its textContent in the Properties window to &amp;quot;Please Enter Your Name&amp;quot;.&lt;br /&gt;
# Add a TextBox. It should name itself TextBox1. In this tutorial, we rename it to Text1.&lt;br /&gt;
# Add 4 more labels with textContent of &amp;quot;Enter Your Birthday&amp;quot;,&amp;quot;Select Month&amp;quot;,&amp;quot;Select Day&amp;quot; and &amp;quot;Select Year&amp;quot;. There are some prettier date pickers we could have used, but we would learn less...&lt;br /&gt;
# Add 3 Select controls, drag into position and resize.&lt;br /&gt;
# Finally add a Button to the form. Resize and change the value property to read &amp;quot;Show Day of The Week&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Form 1 should now look like this:&lt;br /&gt;
&lt;br /&gt;
[[File:TT02.02.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add a new form ===&lt;br /&gt;
&lt;br /&gt;
On the IDE menu select &amp;quot;Project&amp;quot; followed by &amp;quot;Add Form&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Create Objects for Form 2 ===&lt;br /&gt;
&lt;br /&gt;
# Add a Title Bar (HeaderBar) for form2. In the Properties Window set the rightButtonIconPos to &amp;quot;none&amp;quot;, the rightButtonName to blank and change leftButtonName to &amp;quot;Prev&amp;quot;. Set the Title to Page 2. Set leftChangeForm to Form1.&lt;br /&gt;
# Add 3 labels, drag into position and resize.&lt;br /&gt;
# In the properties for each label change the Text property to &amp;quot;Welcome&amp;quot;, &amp;quot;Your Birthday is&amp;quot; and &amp;quot;Your Birthday is on&amp;quot;.&lt;br /&gt;
# Now add 3 Text boxes and drag into position.&lt;br /&gt;
# Lastly add a Button. Resize and change the value to read &amp;quot;Return to previous Page&amp;quot;. Set changeform to Form1.&lt;br /&gt;
&lt;br /&gt;
Form 2 should look like this:&lt;br /&gt;
[[File:TT02.03.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We have completed the visual design of our program so now it&#039;s time to add code to make it do something.&lt;br /&gt;
&lt;br /&gt;
We can actually run the program now. Choose Run...Start in Desktop Browser.&lt;br /&gt;
It runs in your default browser: we recommend using Chrome or Safari, as these support the WebKit extensions which mobile devices use.&lt;br /&gt;
We could even run this on a device, but let&#039;s do a bit more first...&lt;br /&gt;
&lt;br /&gt;
=== Add code to Form 1 ===&lt;br /&gt;
&lt;br /&gt;
Open the code window for Form1 from the Project Explorer window and enter the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&#039; Form1 Code &lt;br /&gt;
Dim birthday, dayofweek&lt;br /&gt;
Dim a,b,c&lt;br /&gt;
&lt;br /&gt;
Sub Main()&lt;br /&gt;
  Select1.clear()&lt;br /&gt;
  For i=0 To 11&lt;br /&gt;
    Select1.addItem(i+1)&lt;br /&gt;
  Next&lt;br /&gt;
  Select2.clear()&lt;br /&gt;
  For i=0 To 30&lt;br /&gt;
    Select2.addItem(i+1)&lt;br /&gt;
  Next&lt;br /&gt;
  Select3.clear()&lt;br /&gt;
  For i=0 To 110&lt;br /&gt;
    Select3.addItem(i+1900)&lt;br /&gt;
  Next&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The 3 Select control loops above set up the Months 1 to 12, the Days 1 to 31 and the Years 1900 to 2010.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&#039; Check to see if Select has recieved an input&lt;br /&gt;
&#039; Select (combo box) for month &lt;br /&gt;
Function Select1_onchange()&lt;br /&gt;
  a=Select1.selectedItem() &lt;br /&gt;
  &#039;MsgBox &amp;quot;selectedIndex is &amp;quot; &amp;amp; Select1.selectedIndex() &amp;amp; &amp;quot; with value &amp;quot; &amp;amp; a &lt;br /&gt;
End Function&lt;br /&gt;
&lt;br /&gt;
Function Select2_onchange()&lt;br /&gt;
 &#039; Select (combo box) for day &lt;br /&gt;
  b=Select2.selectedItem()&lt;br /&gt;
  &#039;MsgBox &amp;quot;selectedIndex is &amp;quot; &amp;amp; Select2.selectedIndex() &amp;amp; &amp;quot; with value &amp;quot; &amp;amp; b&lt;br /&gt;
End Function&lt;br /&gt;
&lt;br /&gt;
Function Select3_onchange()&lt;br /&gt;
  &#039; Select (combo box) for year &lt;br /&gt;
  c=Select3.selectedItem()&lt;br /&gt;
  &#039;MsgBox &amp;quot;selectedIndex is &amp;quot; &amp;amp; Select3.selectedIndex() &amp;amp; &amp;quot; with value &amp;quot; &amp;amp; c &lt;br /&gt;
End Function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The three above functions assign the selections from the ComboBoxes to three variables a, b and c.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Function Button1_onclick()&lt;br /&gt;
  birthday = a &amp;amp; &amp;quot;/ &amp;quot; &amp;amp; b &amp;amp; &amp;quot;/ &amp;quot; &amp;amp; c &lt;br /&gt;
  &#039;MsgBox &amp;quot;Birthday = &amp;quot; &amp;amp; birthday &lt;br /&gt;
  TextBox1.value = Text1.value&lt;br /&gt;
  TextBox2.value = birthday&lt;br /&gt;
  dayofweek = Weekday(birthday) &lt;br /&gt;
  &#039;MsgBox &amp;quot;Day of Week = &amp;quot; &amp;amp; dayofweek &lt;br /&gt;
  TextBox3.value = WeekdayName (dayofweek)&lt;br /&gt;
  ChangeForm(Form2)&lt;br /&gt;
End Function&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When Button1 is clicked, the following happens.&lt;br /&gt;
&lt;br /&gt;
* The values of a, b and c are concatenated together with &amp;quot;/ &amp;quot; to form MM/ DD/ YYYY which is assigned to birthday.&lt;br /&gt;
* The internal WeekDay function is called and the Weekday value is assigned to dayofweek.&lt;br /&gt;
* The internal WeekdayName function is called and the WeekDayName value is assisgned to Text4 which will appear on the form2.&lt;br /&gt;
* Form1 is hidden and Form2 appears.&lt;br /&gt;
&lt;br /&gt;
=== Save the project ===&lt;br /&gt;
&lt;br /&gt;
From the IDE menu select &amp;quot;File&amp;quot; then &amp;quot;Save Project&amp;quot; or &amp;quot;Ctrl S&amp;quot; or the Save Icon from the Tool Bar.&lt;br /&gt;
&lt;br /&gt;
=== Run the program ===&lt;br /&gt;
&lt;br /&gt;
We can run the program again. Choose Run...Start in Desktop Browser.&lt;br /&gt;
If all goes well the forms should appear similar to those shown below.&lt;br /&gt;
&lt;br /&gt;
[[File:TT02.04.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Deploy the App ===&lt;br /&gt;
&lt;br /&gt;
Congratulations...&lt;br /&gt;
The only thing left to do is deploy the program.&lt;/div&gt;</summary>
		<author><name>Debinbrier</name></author>
	</entry>
	<entry>
		<id>https://wiki.appstudio.dev/index.php?title=Testing_and_Deploying&amp;diff=2557</id>
		<title>Testing and Deploying</title>
		<link rel="alternate" type="text/html" href="https://wiki.appstudio.dev/index.php?title=Testing_and_Deploying&amp;diff=2557"/>
		<updated>2013-02-26T13:46:33Z</updated>

		<summary type="html">&lt;p&gt;Debinbrier: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The easiest way to test your app is in your desktop browser. Use “Start in Desktop Browser” under the Run menu. It will run in your default browser, which should support WebKit. At this time, Chrome and Safari support WebKit. &lt;br /&gt;
&lt;br /&gt;
You can debug your program using the desktop browser. For more information, see “[[Using the Chrome Debugger]]”. &lt;br /&gt;
&lt;br /&gt;
Once your program runs well in the desktop browser, you can deploy it to a server. Devices can then load your program from that server. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;Start Up Time&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There are two parts to the startup: the Translation (which happens on the desktop) and the actual startup on the device.&lt;br /&gt;
&lt;br /&gt;
The Translation time will increase as the size of the app increases. Each time you run, any modules which have changed need to be retranslated. If you run twice in a row without changing your app, no translation needs to be done.&lt;br /&gt;
&lt;br /&gt;
You can make Translation faster by splitting your project into more modules. That way, not as much needs to be translated each time. It&#039;s also a good way to organize your code to make it more maintainable.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Deploying&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
App Studio provides a server for testing apps, called the nsbapp.com. When you choose Deploy from the menu, your program and any files listed on the manifest are copied to the server. When the upload is complete, the IDE will give you the URL to open the app from. &lt;br /&gt;
&lt;br /&gt;
The first time the app is run on the device, the files on the manifest are copied to the device. Your app can then be run locally, without an internet connection. &lt;br /&gt;
&lt;br /&gt;
If you change your program and upload it again, there is a pause while the files are moved into place on nsbapp.com. &lt;br /&gt;
&lt;br /&gt;
The next time you run the program (or refresh), the device runs its current version from memory while it gets the latest manifest from the server. It compares them: if the manifest has changed, it then downloads the whole application again and saves it to the device. Once this is complete, the new version of the app will run next time you do a refresh.&lt;br /&gt;
&lt;br /&gt;
For more information, see [[Distributing_your_App|Tech Note 05, “Distributing your App”]].&lt;/div&gt;</summary>
		<author><name>Debinbrier</name></author>
	</entry>
</feed>