0% found this document useful (0 votes)
37 views2 pages

In Put Out Put Dialog Boxes

The document discusses input and output dialog boxes in Visual Basic, specifically the MsgBox and InputBox functions. MsgBox is used to output information to the user in a popup message box. InputBox is used to get input from the user in a popup dialog box that returns a string. Both functions take required and optional arguments like the prompt text, title, and default values. The document provides examples of using each function, and notes how to convert between string and numeric values when using InputBox.

Uploaded by

Alex Lake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

In Put Out Put Dialog Boxes

The document discusses input and output dialog boxes in Visual Basic, specifically the MsgBox and InputBox functions. MsgBox is used to output information to the user in a popup message box. InputBox is used to get input from the user in a popup dialog box that returns a string. Both functions take required and optional arguments like the prompt text, title, and default values. The document provides examples of using each function, and notes how to convert between string and numeric values when using InputBox.

Uploaded by

Alex Lake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Input and Output dialog boxes

Use of
MsgBox function to display information and

InputBox function to input information

See also: http://msdn.microsoft.com/en-us/library/aa445082(v=VS.60).aspx


http://msdn.microsoft.com/en-us/library/aa445028(v=VS.60).aspx

MsgBox
Used to output information to the user
Syntax:

MsgBox ( prompt [, buttons, title ] )

Prompt is a required argument ( a string ), the rest is optional.


(1)
MsgBox ( " Goodbye! ")
(2)
MsgBox ( " x = " & x)

(3)
Dim str as String
str = MsgBox ( Proceed?, vbQuestion + vbYesNo )
If str = vbYes Then
' Take action(s) to proceed
End If
' This displays a message box with the prompt proceed? ,
' a question mark icon (vbQuestion) and two command buttons
' labeled Yes and No (vbYesNo ).
' The answer is placed in variable str.

(4)
Msgbox ( " Result is " & FtoC( f ) )

' Result from call to FtoC () function is placed in msgbox

(5)
MsgBox ( " Hours worked = " & Hours & "Rate of pay = " & Rate & _
vbNewLine & "Wages = " & Wage )
' Underscore ( _ ) allows statement to be continued to next line. vbNewLine moves cursor to next line.
B. Reinhardt, Computing, Faculty of Engineering, DIT, Bolton St.

InputBox
Used to get input from the user.

Syntax:

InputBox ( prompt [, title, default ] )

Prompt is the required message in the input box, title is the title for the input box and
default is the default value to be displayed in the input box. Both title and default are
optional.

Example:
(1)
Dim sName as String
sName = InputBox( "Enter your name > ", "Name", "Joe" )
Enter your name is the prompt, Name is the inputbox title and Joe is the default
value.
InputBox returns a string value, here placed in variable sName.

Inputting numbers
To get the user to input a number instead of text, you must convert the string value into a
number using the Val function.
Example:
Dim hh as String, hours as Integer
hh = InputBox ( " Enter hours worked > ", "Hours worked", 40 )
hours = Val(hh)

'Converts string number into a real number. Example "45" is converted into 45.

Or
hh = val( InputBox ( " Enter hours worked > ", "Hours worked", 40 ) )
Note to convert a number to a string use the Str() function. Example Str( 456) returns
"456"
B. Reinhardt, Computing, Faculty of Engineering, DIT, Bolton St.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy