| Month Function |
Microsoft.VisualBasic.DateAndTime
Month( datevalue )
Date variable or literal date
An Integer between 1 and 12
Returns an integer representing the month of the year of a given date expression
If datevalue contains Nothing , Month returns Nothing .
The validity of the date expression, as well as the position of the month element within the date expression, is initially determined by the locale settings of the current Windows system. However, some intelligence has been built into the Month function that surpasses the usual comparison of a date expression to the current locale settings. For example, on a Windows machine set to US date format ( mm/dd/yyyy ), the date "13/12/1998" would technically be illegal. However, the Month function returns 12 when passed this date. The basic rule for the Month function is that if the system-defined month element is outside legal bounds (i.e., greater than 12), the system-defined day element is assumed to be the month and is returned by the function.
Since the IsDate function adheres to the same rules and assumptions as Month , it can be used to determine whether a date is valid before passing it to the Month function.
Visual Basic also has a new
MonthName
function for returning the
You can also use the DatePart function.
Day Function, Year Function
| MonthName Function |
Microsoft.VisualBasic.DateAndTime
MonthName( month [, abbreviate ])
The ordinal number of the month, from 1 to 12
A flag to
String containing the name of the specified month
Returns the month name of a given month. For example, a month of 1 returns January or (if abbreviate is True ) Jan.
The default value for abbreviate is False .
Public Function GetMonthName(dat As Date) As String Dim iMonth As Integer = Month(dat) GetMonthName = MonthName(iMonth) End Function
month must be an integer; it cannot be a date. Use DatePart("m", dateval ) to obtain a month number from a date.
If
month
has a
MonthName with abbreviate set to False is the equivalent of Format(dateval, "mmmm") .
MonthName with abbreviate set to True is the equivalent of Format(dateval, "mmm") .
WeekdayName Function
| MsgBox Function |
Microsoft.VisualBasic.Interaction
MsgBox( prompt [, buttons ][, title ])
The text of the message to display in the message box dialog box
The sum of the Button , Icon , Default Button , and Modality constant values
The title displayed in the title bar of the message box dialog box
A
MsgBoxResult
enumeration constant indicating the button clicked by the
Displays a dialog box containing a message, buttons, and optional icon to the user. The action taken by the user is returned by the function in the form of an enumerated constant.
prompt
can contain approximately 1,000
If the
title
parameter is omitted, the
If you omit the buttons argument, the default value is 0; that is, VB opens an application modal dialog box containing only an OK button.
The constants of the MsgBoxStyle enumeration can be added together to form a complete buttons argument. The constants can be divided into the following groups:
Only one constant from each
|
Constant |
Value |
Buttons to display |
|---|---|---|
MsgBoxStyle.OKOnly |
OK only |
|
MsgBoxStyle.OKCancel |
1 |
OK and Cancel |
MsgBoxStyle.AbortRetryIgnore |
2 |
Abort, Retry, and Ignore |
MsgBoxStyle.YesNoCancel |
3 |
Yes, No, and Cancel |
MsgBoxStyle.YesNo |
4 |
Yes and No |
MsgBoxStyle.RetryCancel |
5 |
Retry and Cancel |
|
Constant |
Value |
Icon to display |
|---|---|---|
MsgBoxStyle.Critical |
16 |
Critical Message |
MsgBoxStyle.Question |
32 |
Warning Query |
MsgBoxStyle.Exclamation |
48 |
Warning Message |
MsgBoxStyle.Information |
64 |
Information Message |
|
Constant |
Value |
Default button |
|---|---|---|
MsgBoxStyle.DefaultButton1 |
First button |
|
MsgBoxStyle.DefaultButton2 |
256 |
Second button |
MsgBoxStyle.DefaultButton3 |
512 |
Third button |
MsgBoxStyle.DefaultButton4 |
768 |
Fourth button |
|
Constant |
Value |
Modality |
|---|---|---|
MsgBoxStyle.ApplicationModal |
Application |
|
MsgBoxStyle.SystemModal |
4096 |
System |
The following intrinsic constants can be used to determine the action taken by the user and represent the value returned by the MsgBox function:
|
Constant |
Value |
Button clicked |
|---|---|---|
MsgBoxResult.OK |
1 |
OK |
MsgBoxResult.Cancel |
2 |
Cancel (or Esc key pressed) |
MsgBoxResult.Abort |
3 |
Abort |
MsgBoxResult.Retry |
4 |
Retry |
MsgBoxResult.Ignore |
5 |
Ignore |
MsgBoxResult.Yes |
6 |
Yes |
MsgBoxResult.No |
7 |
No |
If the MsgBox contains a Cancel button, the user can press the Esc key and the function's return value will be that of the Cancel button.
Application modality
means that the user cannot access other
System modality
used to mean that all applications were
Unlike its
InputBox
If your application is to run out-of-process on a remote machine, you should remove all MsgBox functions since they will not be displayed to the user, but instead will appear on the monitor of the remote server!
MsgBox should never be used in ASP.NET applications.
In VB 6, the
MsgBox
function has five parameters. The last two,
helpfile
(which specified the
InputBox Function