Dialogs - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

Dialogs

Description:

Icon. Buttons. MsgBox Example. MsgBox 'GoNow',vbExclamation vbOk, 'Leave ... Icon button. Title. Two Events. QueryUnload - Occurs before unloading a form ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 28
Provided by: johnn76
Category:
Tags: dialogs | icon

less

Transcript and Presenter's Notes

Title: Dialogs


1
Dialogs
2
Dialogs
  • Message Boxes
  • Statement MsgBox _
  • Function - returns which button pressed
  • eg. Returnval MsgBox(Hello, vbYesNo)
  • Input Box text box with a message
  • Common Dialogs - Window standards
  • Custom Dialogs - Forms for single message or
    function

3
Message Box
  • Title,
  • Text Message
  • Icon
  • Buttons

4
MsgBox Example
  • MsgBox GoNow,vbExclamation vbOk, Leave
    Instructions

Message
Icon button
Title
5
Two Events
  • QueryUnload - Occurs before unloading a form
  • Unload - Occurs after a form unloads

6
MsgBox Function
  • MsgBox(prompt, buttons , title , helpfile,
    context)

7
prompt Required. String expression displayed as
the message in the dialog box. The maximum length
of prompt is approximately 1024 characters,
depending on the width of the characters used. If
prompt consists of more than one line, you can
separate the lines using a carriage return
character (Chr(13)), a linefeed character
(Chr(10)), or carriage return linefeed
character combination (Chr(13) Chr(10)) between
each line.
8
buttons Optional. Numeric expression that is the
sum of values specifying the number and type of
buttons to display, the icon style to use, the
identity of the default button, and the modality
of the message box. If omitted, the default value
for buttons is 0.
9
title Optional. String expression displayed in
the title bar of the dialog box. If you omit
title, the application name is placed in the
title bar.
10
helpfile Optional. String expression that
identifies the Help file to use to provide
context-sensitive Help for the dialog box. If
helpfile is provided, context must also be
provided. context Optional. Numeric expression
that is the Help context number assigned to the
appropriate Help topic by the Help author. If
context is provided, helpfile must also be
provided.
11
MsgBox Function Example
Dim Msg, Style, Title, Help, Ctxt, Response,
MyString Msg "Do you want to continue ?"
Style vbYesNo vbCritical vbDefaultButton2
Title "MsgBox Demonstration" Help
"DEMO.HLP" Ctxt 1000 ' context.
' Display message. Response MsgBox(Msg,
Style, Title, Help, Ctxt) If Response vbYes
Then MyString "Yes" ' Perform some
action. Else MyString "No" ' Perform
some action. End If
12
The buttons argument settings are
Constant Value Description vbOKOnly 0 Displa
y OK button only. vbOKCancel 1 Display OK and
Cancel buttons. vbAbortRetryIgnore 2 Display
Abort, Retry, and Ignore buttons. vbYesNoCancel
3 Display Yes, No, and Cancel buttons. vbYesNo
4 Display Yes and No buttons. vbRetryCancel 5 Di
splay Retry and Cancel buttons.
13
Icons
vbCritical 16 Display Critical Message icon.
vbQuestion 32 Display Warning Query
icon. vbExclamation 48 Display Warning Message
icon. vbInformation 64 Display Information
Message icon.
14
Default Button
vbDefaultButton1 0 First button is
default. vbDefaultButton2 256 Second button is
default. vbDefaultButton3 512 Third button is
default. vbDefaultButton4 768 Fourth button is
default.
15
Modalities
vbApplicationModal 0 Application modal the user
must respond to the message box before
continuing work in the current application. vbSys
temModal 4096 System modal all applications are
suspended until the user responds to the
message box. vbMsgBoxHelpButton 16384 Adds Help
button to the message box VbMsgBoxSetForeground 6
5536 Specifies the message box window as the
foreground window vbMsgBoxRight 524288 Text is
right aligned vbMsgBoxRtlReading 1048576 Specifie
s text should appear as right-to-left
reading on Hebrew and Arabic systems
16
When adding numbers to create a final value for
the buttons argument, use only one number from
each group.
17
Return Values
  • Constant Value Description
  • vbOK 1 OK
  • vbCancel 2 Cancel
  • vbAbort 3 Abort
  • vbRetry 4 Retry
  • vbIgnore 5 Ignore
  • vbYes 6 Yes
  • vbNo 7 No

18
Generic Error Message
Private Function ErrorMsg(ByVal strMessage As
String, ByVal blnCancelled As Boolean) As Long
If blnCancelled Then ErrorMsg
MsgBox("Sorry." vbCr strMessage vbCr _
"Operation Cancelled.", vbOKOnly
vbInformation, My Application)
Else ErrorMsg MsgBox("Error"
vbCr strMessage vbCr, _ vbOKOnly
vbExclamation, My Application) End
If End Function
19
Call to Generic Error Message
ErrorMsg "Attempt to save document " _
DocName " failed.", True
20
Input Box Example
InputBox( Enter Name, Login, Paul Jones)
Message
Default
Caption/Title
  • Input Boxes cant be programmed
  • One piece of information only
  • Dont look great

21
Common Dialog
Method Dialog Displayed ShowOpen Show Open
Dialog Box ShowSave Show Save As Dialog
Box ShowColor Show Color Dialog
Box ShowFont Show Font Dialog Box ShowPrinter Sh
ow Print or Print Options Dialog
Box ShowHelp Invokes the Windows Help Engine
22
  • The CommonDialog control automatically provides
  • context sensitive help on the interface of the
    dialog boxes
  • by clicking
  • The What's This help button in the title bar
  • then clicking the item for which you want
  • more information.
  • The right mouse button over the item
  • for which you want more information then
  • selecting the What's This command in the
  • displayed context menu.

23
Note There is no way to specify where a dialog
box is displayed.
24
File Handling Introduction
  • Sequential Files text files stored of ANSI
    charaters - .txt extension
  • Random Access Files - (text) you can define the
    structure and access randomly
  • Binary files - no structure, smaller

25
Sequential Files
Dim intFileNumber as Integer intFileNumber
FreeFile Unique label Open TextFile.txt For
Input As intFileNumber easier to read
26
Input
  • varInputFromFile Input(100, intFile)
  • by number of characters
  • varInputFromFile Input(LOF(intFile), intFile
  • length of file whole thing
  • Input intFile, sName, nPhoneNumber
  • ends with cr (13) and line feed (10)
  • delimeted

27
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com