1 / 8

Section 3.5 - Schneider

Learn how to use input boxes to receive data from users and message boxes to display output. Examples and formatting options included.

mnina
Download Presentation

Section 3.5 - Schneider

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. Section 3.5 - Schneider • This section introduces nice ways to produce input & display output: • Input boxes • Message boxes

  2. Input Boxes (Section 3.5) • An input box is an object that appears on the form solely for the purpose of receiving data to the program. Once the data is entered by the user, the box disappears. • str_var = InputBox(prompt,title) Variable to receive input data Caption Identifies the object Instruction to user

  3. Private Sub Command1_Click() Dim Char As String, message1 As String Dim message2 As String Dim x As Single Picture1.Cls message1 = "Please enter a character string" message2 = "Please enter a 3-digit number" Char = InputBox(message1,”Character input”) x = Val(InputBox(message2,”Numeric input”)) Picture1.Cls Picture1.Print Char Picture1.Print x * 2 End Sub

  4. Notes on Input boxes • We can use an input box if we want a user to provide input data to a program. The input boxappears when an event procedure invokes it and it disappears when the user clicks on OK or presses the Enter key. • The data entered is character string type. • Compare an input box to a text box

  5. Message Boxes • Same idea as input boxes; object appears for the purpose of displaying output and then it disappears from sight. • MsgBoxprompt,, title • MsgBox “Better luck next time”, , “Hello” Identifies the object Message to user Caption

  6. Formatting Output • Vertical - Each PictureBox.Print causes a new line to display; no argument causes a line skip • Horizontal - • ; or , print zones (p. 104) • Tab(n) - nth position of line (p. 105) • Spc(n) insert n spaces • Format (pp. 122 - 124)

  7. Today’s Lab • Page 116 #49, 51

  8. Homework Assignment (HW4) • Due next Tuesday • Page 117 #53. There is no input. Write code to calculate the total. Display the results in a picture box. • Page 117 #54. Make a command button and a picture box. When the button is clicked an input box appears. The user should enter the amount of the bill. Another input box then appears to collect the percentage tip. Display the results in the picture box.

More Related