1 / 12

Microsoft ® Small Basic

Microsoft ® Small Basic. The Controls Object. Estimated time to complete this lesson: 1 hour. The Controls Object. In this lesson, you will learn how to:. Use various properties of the Controls object. Use control events on buttons and text boxes in your program.

bernie
Download Presentation

Microsoft ® Small Basic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Microsoft® Small Basic The Controls Object Estimated time to complete this lesson: 1 hour

  2. The Controls Object In this lesson, you will learn how to: • Use various properties of the Controls object. Use control events on buttons and text boxes in your program. Use various operations of the Controls object.

  3. Introduction to the Controls Object • This lesson introduces you to the Controls object that Small Basic offers. By using this object, you can display simple controls, such as text boxes and buttons, in the graphics window. So far, you have learned to use different objects in Small Basic, such as the GraphicsWindow, Shapes, File, and Math objects.

  4. Operations of the Controls Object • Before we create a program by using the Controls object, let’s learn about some operations of the Controls object and their parameters. • AddTextBox—You can define a text box that will appear in the graphics window by using this operation. As parameters, you must specify the text box’s x-coordinate and • y-coordinate. • AddButton—You can define a button that will appear in the graphics window by using this operation. As parameters, you must specify the button’s caption and its x-coordinate and y-coordinate.

  5. Operations of the Controls Object • GetButtonCaption—By using this operation, you can retrieve the caption of a button. You must specify the name of the button as a parameter. • SetButtonCaption—By using this operation, you can set or change the caption of a button. You must specify the name of the button and the new caption as parameters. • GetTextBoxText—You can retrieve the text that appears in a text box by specifying its name asa parameter for this operation. • SetTextBoxText—You can define the text to appear in a text box by specifying its name and the required text as parameters for this operation.

  6. Operations of the Controls Object • In addition to adding useful controls into your program, you can perform certain operations and define the settings for the controls that you add. Let’s explore the Controls object with the help of an example.

  7. Properties and Operations of the Controls object Let’s look at the capabilities that a few more operations and properties of the Controls object offer. • HideControl—You can use this operation to hide an existing control from the graphics window. • ShowControl—You can use this operation to display a previously hidden control in the graphics window. • Remove—You can use this operation to remove a control from the graphics window.

  8. Properties and Operations of the Controls object • SetSize—You can specify a fixed size for a control by using this operation. You must specify the name, height, and width of the control as parameters. • Move—You can move a control to a different position in the graphics window by using this operation. You must specify the name, left coordinate, and top coordinate of the control as parameters.   LastClickedButton—You can use this operation to find the last button that was clicked on the graphics window. LastTypedTextBox—You can use this operation to find the last text box where text was typed.

  9. The Controls Object • Now let’s write a simple program that includes the Controlsobject. This program displays the definitions of a given word. output

  10. Control Events • Now that you are familiar with the Controls object in Small Basic, let’s get acquainted with the events that you can use for that object. Control events can generate actions in your program when the user clicks a button or types some text into a text box. ButtonClicked raises an event when the user clicks a button. TextTyped raises an event when the user types text into a text box. And here’s an example of the TextTyped event: You can use the ButtonClicked event to make a simple calculator like the one that appears to the right:

  11. Let’s Summarize… Congratulations! Now you know how to: • Usevarious properties of the Controls object. • Use various operations of the Controls object. • Use control events on buttons and text boxes in your program.

  12. Show What You Know Write a program to display a simple form, and perform the following steps: • Add text boxes to request the name, address, telephone number, and e-mail address of the user. • Add a Submit button to the form. • After the user specifies the information and clicks Submit, display an appropriate message.

More Related