Input Output Box

download Input Output Box

of 37

Transcript of Input Output Box

  • 7/29/2019 Input Output Box

    1/37

    INPUT & OUTPUT

    BOX

  • 7/29/2019 Input Output Box

    2/37

    Input and Output boxare the

    built-in functions (or internalfunctions) created in Visual

    Basic.

    BOX

  • 7/29/2019 Input Output Box

    3/37

    An input boxis a specially designed

    dialog box that allows the

    programmer to request a valuefrom the user and use that value as

    necessary.

    INPUT BOX

  • 7/29/2019 Input Output Box

    4/37

    Message/

    prompt

    Text box

    Command

    Button

    Command

    Button

    Title bar

    The Interface

  • 7/29/2019 Input Output Box

    5/37

    It contains:

    A message/prompt - to indicate the

    requested value.A textbox for user to enter data.

    2 command buttons (Ok, Cancel) - used to

    accept or cancel input data.

    A Title to show the title of the input box

    INPUT BOX

  • 7/29/2019 Input Output Box

    6/37

    InputBox (prompt, title , default option , x position, y position)

    SYNTAX/CODE

    Argument Description

    Prompt String expression displayed as the message in

    the dialog box. It is required.

    Title String expression displayed in the title bar of the

    dialog box.

    Default option String expression displayed in the text box as the

    default response if no other input is provided. Ifyou omit default option, the text box is displayedempty.

    x position, y

    position

    Numeric expressions that specify custom

    positioning of the box on screen.

  • 7/29/2019 Input Output Box

    7/37

    Design the application as shown below:

    Lets try to apply the inputboxfunction

    Label

    name : lblShow

    Caption : Show Name Here

    Command button

    Name : cmdInput

    Caption : Input

  • 7/29/2019 Input Output Box

    8/37

    Now, we can use the inputboxfunction

    Double click button and writethe following code:

    Dim Nama As StringNama = InputBox(Enter your full name: )

    Run your program

  • 7/29/2019 Input Output Box

    9/37

    1. Click Inputbutton

    Then the input box will appear as shown below

    Message/prompt

  • 7/29/2019 Input Output Box

    10/37

    Stop your program, back to your coding and addthe following blue colourcode:

    InputBox(Enter your full name: , Input Name)

    Run your program again and find the changes that

    happen in the input box

    Lets try to add title to the inputbox

  • 7/29/2019 Input Output Box

    11/37

    The title will change

  • 7/29/2019 Input Output Box

    12/37

    Lets try to add default optionto the input box

    the default option will display a default value in thetextbox of the input box.

    Stop your program, back to your coding and add

    the following blue colourcode:

    InputBox(Enter your full name: , Input Name

    , UPPER CASE ONLY)

    Run your program again and find the changes that

    happen in the input box

  • 7/29/2019 Input Output Box

    13/37

    Default value

  • 7/29/2019 Input Output Box

    14/37

    Lets try to add positionto the input box

    Stop your program, back to your coding and addthe following blue colourcode:

    InputBox(Enter your full name: , Input Name ,

    , UPPER CASE ONLY, 10,3000)

    Run your program again.

  • 7/29/2019 Input Output Box

    15/37

    What happen to the

    input box?

  • 7/29/2019 Input Output Box

    16/37

    The code will change

    the position of the

    input box

  • 7/29/2019 Input Output Box

    17/37

    So, the syntax of the input box

    function is:

    InputBox(Prompt, title, default

    option,x position, y position)

  • 7/29/2019 Input Output Box

    18/37

    exercise

    How to show your name on the

    label you created before?

  • 7/29/2019 Input Output Box

    19/37

    Stop your program, back to your coding and add

    the following code. Make sure you add the code

    after the Inputbox function code.

    lblShow.Caption = nama

    Run your program again.

  • 7/29/2019 Input Output Box

    20/37

    1. Click button

    input

    3. Click button

    OK

    2. Enter your

    name

  • 7/29/2019 Input Output Box

    21/37

    Whatever you entered

    in the textbox will

    appear here

  • 7/29/2019 Input Output Box

    22/37

    The function of Output box :

    Display information to the user. A

    useful dialog box function fordisplaying output is the MsgBox

    (Message box)

    OUTPUT BOX

  • 7/29/2019 Input Output Box

    23/37

    Icon

    message

    Button

    Title bar

  • 7/29/2019 Input Output Box

    24/37

    MsgBox(Message) , Button type + icon type ,title

    SYNTAX/CODE

    Argument Description

    Message String expression displayed as the messagein the Message box. It is required

    Button , icon Numeric expression that is the sum of values

    specifying the number and type of buttons to

    display and the icon style to use.

    title String expression displayed in the title bar of

    the dialog box. If you omit title, theapplication name is placed in the title bar.

  • 7/29/2019 Input Output Box

    25/37

    Continue the previous exercise (input box). Applythe following code. Make sure you write the code

    below the previous code (lblShow.Caption = nama)

    MsgBox(Hello )

    Run your program

    Lets try to apply the outputboxfunction

  • 7/29/2019 Input Output Box

    26/37

    The pop up message will appear as shown below

  • 7/29/2019 Input Output Box

    27/37

    Button & Icon in theoutputbox function

  • 7/29/2019 Input Output Box

    28/37

    BUTTONok0

    ok, Cancel1

    Abort, Retry, Ignore2

    Yes, No, Cancel3

    Yes, No4Retry, Cancel5

  • 7/29/2019 Input Output Box

    29/37

    ICON

    16

    32

    48

    64

  • 7/29/2019 Input Output Box

    30/37

    Stop your program, back to your coding and addthe following blue colourcode:

    MsgBox(Hello ), 3 + 32

    Run your program.

    Lets try to apply button & icon in theoutputbox function

  • 7/29/2019 Input Output Box

    31/37

    Icon

    Button

  • 7/29/2019 Input Output Box

    32/37

    Stop your program, back to your coding and addthe following blue colourcode:

    MsgBox(Hello ) , 3 + 32 , Message Box

    Run your program.

    Lets try to add title in the outputboxfunction

  • 7/29/2019 Input Output Box

    33/37

    The title will appear

    here

  • 7/29/2019 Input Output Box

    34/37

    So, the syntax of the output box

    function is:

    MsgBox(Message) , button+icon, title

    How to add name in the Output

  • 7/29/2019 Input Output Box

    35/37

    How to add name in the Outputbox

  • 7/29/2019 Input Output Box

    36/37

    Stop your program, back to your coding and add

    the following blue colourcode:

    MsgBox(Hello ) & nama, 3 + 32 , Message Box

    Run your application

  • 7/29/2019 Input Output Box

    37/37

    Thats all for todayThank you!