NewCalendar

Description

Adds a calendar (date picker) control to a form

Syntax

[Set oCtl =] oFrm.NewCalendar

( Name, Left, Top, Width, Height, [Day], [Month], [Year], [Container] )

Parameters

Part

Description

Set oCtl =

(optional) Store a reference to the new control in the variable oCtl. This variable can be used to access the control's properties and methods

oFrm

A reference to a form object (see the NewForm method)

Name

The name of the control. It must be unique within the form and may not be empty or start with an asterisk (*)

Left

See the list of properties below

Top

See the list of properties below

Width

See the list of properties below

Height

See the list of properties below

Day

(optional) See the list of properties below

Month

(optional) See the list of properties below

Year

(optional) See the list of properties below

Container

(optional) The name of an existing frame control that will act as container for the calendar. If unspecified or an empty string, the Form itself will be the container. Please note that the Left and Top properties are relative to the container's left and top edges

Properties, Methods and Events

Property

Description

BackColor

Background color (use the RGB function to assign a color value)

Day

Returns or sets the day of the month (1 - 31)

DayFont

Defines the font used to display the days of the week above the grid.
The DayFont property returns an object which has additional properties you can set : Name, Size, Bold, Italic, UnderLine and StrikeThrough

DayFontColor

The color for the DayFont (use the RGB function to assign a color)

DayLength

The display format for the days of the week

0

Short : S, M, T, W, T, F, S (default)

1

Medium : Sun, Mon, Tue, Wed, Thu, Fri, Sat

2

Long : Sunday, Monday, and so on

FirstDay

The first day of the week, 1 for Sunday, 2 for Monday, and so on

GridCellEffect

The effect used for the calendar grid

0

Flat

1

Raised (default)

2

Sunken

GridFont

Defines the font used to display the days of the month in the grid.
The GridFont property returns an object which has additional properties you can set : Name, Size, Bold, Italic, UnderLine and StrikeThrough

GridFontColor

The color for the GridFont (use the RGB function to assign a color)

GridLinesColor

The gridline color for a calendar with a Flat GridCellEffect property (0)

Height

The height of the control in twips

Left

The distance from the left edge of the specified container in twips

Month

Returns or sets the month (1 - 12)

MonthLength

The display format for the month

0

Short : Jan, Feb, Mar, and so on

2

Long : January, February, March, and so on

Parent

(read-only) Returns the parent form, object or collection. You can use the parent property to access the properties and methods of an object's parent

ShowDateSelectors

(boolean) Determines the visibility of the month and year selectors above the grid

ShowDays

(boolean) Determines the visibilty of the days of the week above the grid

ShowHorizontalGrid

(boolean) Determines the visibility of the horizontal gridlines for a calendar control whose GridCellEffect property is set to Flat (0)

ShowTitle

(boolean) Determines the visibility of a month/year title above the grid

ShowVerticalGrid

(boolean) Determines the visibility of the vertical gridlines for a calendar control whose GridCellEffect property is set to Flat (0).

TabStop

(boolean) Determines whether the TAB key can be used to move the focus

Tag

(reserved) Used internally to store the user-defined controlname

TitleFont

Defines the font used to display the month/year title above the grid.
The TitleFont property returns an object which has additional properties you can set : Name, Size, Bold, Italic, UnderLine and StrikeThrough

TitleFontColor

The color for the TitleFont (use the RGB function to assign a color)

ToolTipText

Explanatory text that appears in a small rectangle below the object when you pause the mouse pointer (hover) over it for about one second

Top

The distance from the top edge of the specified container in twips

Value

Returns or sets the currently selected date (or Null).
Valid dates range from 1/1/1900 to 12/31/2100

ValueIsNull

(boolean) Determines if a date will be selected (default) or not.
If this property is True, no date will be selected and Value is set to Null

Visible

(boolean) Determines whether the control is visible or hidden

Width

The width of the control in twips

Year

Returns or sets the year (1900 - 2100)

Method

Description

Move

Parameters: left [, top [, width [, height ]]]

Only the left argument is required. However, to specify any other arguments, you must specify all arguments that appear in the syntax before the argument you want to specify. For example, you can't specify width without specifying left and top. Any trailing arguments that are unspecified remain unchanged

NextDay

Increments the value of the calendar control by one day

NextMonth

Increments the value of the calendar control by one month

NextWeek

Increments the value of the calendar control by one week

NextYear

Increments the value of the calendar control by one year

PreviousDay

Decrements the value of the calendar control by one day

PreviousMonth

Decrements the value of the calendar control by one month

PreviousWeek

Decrements the value of the calendar control by one week

PreviousYear

Decrements the value of the calendar control by one year

Refresh

Forces a complete repaint of a control

Today

Sets the current date to today's date

Event

Description

Event raised

AfterUpdate

Occurs after the user moves to a new date in the control (using either the mouse or the keyboard) and after the calendar has been refreshed

Controlname

To be able to handle events you need to operate a form in callback mode.
This subject is described in the following topics:
Callback forms, ClickHandler

Example

Option Explicit

Const vbModal = 1

Dim oDlg, oFrm, oCtl

'Create the WshDialog.Kit object and store a reference in oDlg
Set oDlg = Wscript.CreateObject("WshDialog.Kit", "oDlg_")

'Add a new form and store a reference to it in the variable oFrm
Set oFrm = oDlg.NewForm("Sample")

'Add a calendar named CAL1 to the oFrm form and store a reference in the variable oCtl
Set oCtl = oFrm.NewCalendar("CAL1", 100, 100, 2500, 3000)

'Use the reference variable to change the month
oCtl.PreviousMonth

'Use the reference variable to change the DayFont and Color
oCtl.DayFont.Bold = False
oCtl.DayFontColor = RGB(255, 0, 0)

'Add an OK button and set it's Default property
Set oCtl = oFrm.NewButton("OK", 900, 3250, 1000, 375, "&OK")
oCtl.Default = True

'Automatically size the form and show it (modally)
oFrm.Autosize
oFrm.Show vbModal

'Show which date was selected (only if the OK button was clicked)
If oDlg.Clicked = "OK" Then
    MsgBox "The selected date is : " & oFrm.Ctl("CAL1").Value
End If