Lesson 08: Int新宇平台roduction to Strings

九段 2019-06-12 05:1485http://www.ldyeya.com/admin

 

Introduction to Strings

 
 

The Message Box

Introduction

 

A message box is a relatively small window that displays a piece of information to the user. As opposed to a regular form, the user cannot type anything in the message box. There are usually two kinds of message boxes you will create: one that simply displays information and one that expects the user to make a decision.

 
   

The function to create a message box is named MsgBox. Its syntax is:

MsgBox([Message] [Buttons] [Title] [HelpFile] [Context])

The MsgBox() function takes five arguments and only the first one is required: the Message.

Practical Learning: Starting Microsoft Access

Start Microsoft Access

Click Blank Desktop Database

Set the File name to Exercise2 and click Create

On the Ribbon, click Create and click Form Design

In the Controls section of the Ribbon, click Button and click the form.
If a wizard starts, click Cancel

Right-click the new button on the form and click Build Event...

In the Choose Builder dialog box, click Code Builder and click OK

The Message of a Message Box

The Message argument is the text that will display on the message box. As a string, you can display it in double quotes.

Practical Learning: Introducing Message Boxes

Type the following line of code: Private Sub Command0_Click() MsgBox "Welcome to the wonderful world of VBA programming." End Sub

Return to Microsoft Access and switch the form to Form View

Click the button

Introducing Message Boxes

Click OK on the message box and return to Microsoft Visual Basic

You can create a message from other pieces of strings. The Message argument can be made of up to 1024 characters. To display the Message on multiple lines, you can use the constant vbCrLf between two strings. For an example, change the code as follows: Private Sub Command0_Click() MsgBox "Your logon credentials have been checked." & _ vbCrLf & "To complete your application, please " & _ "fill out the following survey" End Sub

Return to Microsoft Access and click the button

Message Box

Press Enter on the message box and return to Microsoft Visual Basic

The Buttons on a Message Box

The Buttons argument specifies what button(s) should display on the message box. There are different kinds of buttons available and Visual Basic recognizes them by a numeric value assigned to each. The Buttons argument is a value of the VbMsgBoxStyle enumeration. It can be one of the following members or constants:

VbMsgBoxStyle Member   Constant Value   Button(s) Displayed  
vbOKOnly   0    
vbOKCancel   1    
vbAbortRetryIgnore   2    
vbYesNoCancel   3    
vbYesNo   4    
vbRetryCancel   5    

新宇平台_正规彩票网:Lesson 08: Int新宇平台roduction to Strings

Copyright © 2002-2019 新宇平台_正规彩票网 版权所有 备案号:鄂ICP备12013336号-2 鄂公网安备61032703000198