RAS Playground 日本語 GitHub

Type definitions (Excel, VBA)

VBA

These are the type definitions of the VBA standard library bundled with RAS. Functions, constants and err / debug are at the top level, and types and enums are in the namespace VBA. In RAS source they are written in camelCase (msgBox, inputBox, uBound). The generated VBA uses the spelling given in the "VBA:" of each entry.

File statements such as Open / Print # / Close are written as FileIO functions ("Reading and writing files" in the cheat sheet). For reading and writing with a specified encoding, use fs.

Reference

Interface VBA.ErrObject

Holds information about the most recent run-time error.

Microsoft reference

#
number: int

The error number. 0 means no error.

Microsoft reference

VBA: Number

#
description: string

The description of the error.

Microsoft reference

VBA: Description

#
source: string

The name of the object or application that raised the error.

Microsoft reference

VBA: Source

#
helpFile: string

The path of the help file for the error.

Microsoft reference

VBA: HelpFile

#
helpContext: int

The context ID of the topic in the help file.

Microsoft reference

VBA: HelpContext

#
readonly lastDllError: int

The system error code set by the last DLL call.

Microsoft reference

VBA: LastDllError

#
raise(number: int, source?: any, description?: any, helpFile?: any, helpContext?: any): void

Raises a run-time error.

Microsoft reference

VBA: Raise

#
clear(): void

Clears all the error information.

Microsoft reference

VBA: Clear

vba.d.ras

Interface VBA.Collection

An ordered collection of items. Indexes are 1-based, and items can also be looked up by key string.

Microsoft reference

#
(index: any): any

Returns an item by index or key (default member).

Microsoft reference

#
item(index: any): any

Returns an item by index or key.

Microsoft reference

VBA: Item

#
count(): int

The number of items.

Microsoft reference

VBA: Count

#
add(item: any, key?: any, before?: any, after?: any): void

Adds an item. before / after give the position to insert at.

Microsoft reference

VBA: Add

#
remove(index: any): void

Removes an item by index or key.

Microsoft reference

VBA: Remove

vba.d.ras

Interface VBA.DebugObject

Writes to the Immediate window and makes assertions.

Microsoft reference

#
print(arg1?: cellValue, arg2?: cellValue, arg3?: cellValue, arg4?: cellValue, arg5?: cellValue, arg6?: cellValue, arg7?: cellValue, arg8?: cellValue): void

Writes values to the Immediate window.

Microsoft reference

VBA: Print

#
assert(cond: boolean): void

When the condition is false, suspends execution during development.

Microsoft reference

VBA: Assert

vba.d.ras

Enum VBA.VbMsgBoxStyle

Specifies the buttons, icon, default button and so on of a MsgBox (combined by adding).

Microsoft reference

#
vbOKOnly = 0
#
vbOKCancel = 1
#
vbAbortRetryIgnore = 2
#
vbYesNoCancel = 3
#
vbYesNo = 4
#
vbRetryCancel = 5
#
vbCritical = 16
#
vbQuestion = 32
#
vbExclamation = 48
#
vbInformation = 64
#
vbDefaultButton1 = 0
#
vbDefaultButton2 = 256
#
vbDefaultButton3 = 512
#
vbDefaultButton4 = 768
#
vbApplicationModal = 0
#
vbSystemModal = 4096
#
vbMsgBoxHelpButton = 16384
#
vbMsgBoxSetForeground = 65536
#
vbMsgBoxRight = 524288
#
vbMsgBoxRtlReading = 1048576

vba.d.ras

Enum VBA.KeyCodeConstants

Codes for keyboard keys (the KeyCode of KeyDown / KeyUp events).

Microsoft reference

#
vbKeyLButton = 1
#
vbKeyRButton = 2
#
vbKeyCancel = 3
#
vbKeyMButton = 4
#
vbKeyBack = 8
#
vbKeyTab = 9
#
vbKeyClear = 12
#
vbKeyReturn = 13
#
vbKeyShift = 16
#
vbKeyControl = 17
#
vbKeyMenu = 18
#
vbKeyPause = 19
#
vbKeyCapital = 20
#
vbKeyEscape = 27
#
vbKeySpace = 32
#
vbKeyPageUp = 33
#
vbKeyPageDown = 34
#
vbKeyEnd = 35
#
vbKeyHome = 36
#
vbKeyLeft = 37
#
vbKeyUp = 38
#
vbKeyRight = 39
#
vbKeyDown = 40
#
vbKeySelect = 41
#
vbKeyPrint = 42
#
vbKeyExecute = 43
#
vbKeySnapshot = 44
#
vbKeyInsert = 45
#
vbKeyDelete = 46
#
vbKeyHelp = 47
#
vbKeyNumlock = 144
#
vbKey0 = 48
#
vbKey1 = 49
#
vbKey2 = 50
#
vbKey3 = 51
#
vbKey4 = 52
#
vbKey5 = 53
#
vbKey6 = 54
#
vbKey7 = 55
#
vbKey8 = 56
#
vbKey9 = 57
#
vbKeyA = 65
#
vbKeyB = 66
#
vbKeyC = 67
#
vbKeyD = 68
#
vbKeyE = 69
#
vbKeyF = 70
#
vbKeyG = 71
#
vbKeyH = 72
#
vbKeyI = 73
#
vbKeyJ = 74
#
vbKeyK = 75
#
vbKeyL = 76
#
vbKeyM = 77
#
vbKeyN = 78
#
vbKeyO = 79
#
vbKeyP = 80
#
vbKeyQ = 81
#
vbKeyR = 82
#
vbKeyS = 83
#
vbKeyT = 84
#
vbKeyU = 85
#
vbKeyV = 86
#
vbKeyW = 87
#
vbKeyX = 88
#
vbKeyY = 89
#
vbKeyZ = 90
#
vbKeyNumpad0 = 96
#
vbKeyNumpad1 = 97
#
vbKeyNumpad2 = 98
#
vbKeyNumpad3 = 99
#
vbKeyNumpad4 = 100
#
vbKeyNumpad5 = 101
#
vbKeyNumpad6 = 102
#
vbKeyNumpad7 = 103
#
vbKeyNumpad8 = 104
#
vbKeyNumpad9 = 105
#
vbKeyMultiply = 106
#
vbKeyAdd = 107
#
vbKeySeparator = 108
#
vbKeySubtract = 109
#
vbKeyDecimal = 110
#
vbKeyDivide = 111
#
vbKeyF1 = 112
#
vbKeyF2 = 113
#
vbKeyF3 = 114
#
vbKeyF4 = 115
#
vbKeyF5 = 116
#
vbKeyF6 = 117
#
vbKeyF7 = 118
#
vbKeyF8 = 119
#
vbKeyF9 = 120
#
vbKeyF10 = 121
#
vbKeyF11 = 122
#
vbKeyF12 = 123
#
vbKeyF13 = 124
#
vbKeyF14 = 125
#
vbKeyF15 = 126
#
vbKeyF16 = 127

vba.d.ras

Enum VBA.VbMsgBoxResult

The button pressed in a MsgBox.

Microsoft reference

#
vbOK = 1
#
vbCancel = 2
#
vbAbort = 3
#
vbRetry = 4
#
vbIgnore = 5
#
vbYes = 6
#
vbNo = 7

vba.d.ras

Enum VBA.VbCompareMethod

Specifies how strings are compared.

Microsoft reference

#
vbBinaryCompare = 0
#
vbTextCompare = 1
#
vbDatabaseCompare = 2

vba.d.ras

Enum VBA.VbVarType

The kinds of data type VarType returns.

Microsoft reference

#
vbEmpty = 0
#
vbNull = 1
#
vbInteger = 2
#
vbLong = 3
#
vbSingle = 4
#
vbDouble = 5
#
vbCurrency = 6
#
vbDate = 7
#
vbString = 8
#
vbObject = 9
#
vbError = 10
#
vbBoolean = 11
#
vbVariant = 12
#
vbDataObject = 13
#
vbDecimal = 14
#
vbByte = 17
#
vbLongLong = 20
#
vbUserDefinedType = 36
#
vbArray = 8192

vba.d.ras

Enum VBA.VbDayOfWeek

Specifies a day of the week, or the first day of the week.

Microsoft reference

#
vbUseSystemDayOfWeek = 0
#
vbSunday = 1
#
vbMonday = 2
#
vbTuesday = 3
#
vbWednesday = 4
#
vbThursday = 5
#
vbFriday = 6
#
vbSaturday = 7

vba.d.ras

Enum VBA.VbFirstWeekOfYear

Specifies how the first week of the year is determined.

Microsoft reference

#
vbUseSystem = 0
#
vbFirstJan1 = 1
#
vbFirstFourDays = 2
#
vbFirstFullWeek = 3

vba.d.ras

Enum VBA.VbStrConv

Specifies the character conversion StrConv performs (can be combined by adding).

Microsoft reference

#
vbUpperCase = 1
#
vbLowerCase = 2
#
vbProperCase = 3
#
vbWide = 4
#
vbNarrow = 8
#
vbKatakana = 16
#
vbHiragana = 32
#
vbUnicode = 64
#
vbFromUnicode = 128

vba.d.ras

Enum VBA.VbFileAttribute

Attributes of files and folders (combined by adding).

Microsoft reference

#
vbNormal = 0
#
vbReadOnly = 1
#
vbHidden = 2
#
vbSystem = 4
#
vbVolume = 8
#
vbDirectory = 16
#
vbArchive = 32
#
vbAlias = 64

vba.d.ras

Enum VBA.VbAppWinStyle

Specifies how the window of a program started by Shell is shown.

Microsoft reference

#
vbHide = 0
#
vbNormalFocus = 1
#
vbMinimizedFocus = 2
#
vbMaximizedFocus = 3
#
vbNormalNoFocus = 4
#
vbMinimizedNoFocus = 6

vba.d.ras

Enum VBA.VbCallType

Specifies the kind of procedure CallByName calls.

Microsoft reference

#
VbMethod = 1
#
VbGet = 2
#
VbLet = 4
#
VbSet = 8

vba.d.ras

Enum VBA.VbDateTimeFormat

Specifies the format of FormatDateTime.

Microsoft reference

#
vbGeneralDate = 0
#
vbLongDate = 1
#
vbShortDate = 2
#
vbLongTime = 3
#
vbShortTime = 4

vba.d.ras

Enum VBA.VbTriState

Three states: true, false and the default.

Microsoft reference

#
vbUseDefault = -2
#
vbTrue = -1
#
vbFalse = 0

vba.d.ras

Enum VBA.ColorConstants

RGB values of the basic colors.

Microsoft reference

#
vbBlack = 0
#
vbRed = 255
#
vbGreen = 65280
#
vbYellow = 65535
#
vbBlue = 16711680
#
vbMagenta = 16711935
#
vbCyan = 16776960
#
vbWhite = 16777215

vba.d.ras

Enum VBA.VbCalendar

Specifies the calendar to use.

Microsoft reference

#
vbCalGreg = 0
#
vbCalHijri = 1

vba.d.ras

Enum FileIO.OpenMode

The mode in which fileOpen opens a file (VBA's Open … For <mode>). The values equal the return values of fileAttr(n, 1).

Microsoft reference

#
forInput = 1

Reading (For Input). Error 53 if the file does not exist.

#
forOutput = 2

Writing (For Output). The file is recreated.

#
forRandom = 4

Reading and writing fixed-length records (For Random).

#
forAppend = 8

Appending to the end (For Append).

#
forBinary = 32

Reading and writing bytes (For Binary).

vba.d.ras

Enum FileIO.OpenAccess

The operations fileOpen allows (VBA's Open … Access <access>).

Microsoft reference

#
accessDefault = -1

Not specified (the mode's default).

#
accessRead = 1

Read only (Access Read).

#
accessWrite = 2

Write only (Access Write).

#
accessReadWrite = 3

Read and write (Access Read Write).

vba.d.ras

Enum FileIO.OpenShare

The operations other processes may perform on a file opened with fileOpen (VBA's Open … <lock>).

Microsoft reference

#
lockDefault = -1

Not specified (no Lock clause).

#
lockReadWrite = 0

Both reading and writing are denied (Lock Read Write).

#
lockWrite = 1

Writing is denied (Lock Write).

#
lockRead = 2

Reading is denied (Lock Read).

#
lockShared = 3

Nothing is denied (Shared).

vba.d.ras

Global err

const err: VBA.ErrObject

VBA: Err

Information about the most recent run-time error.

Microsoft reference

vba.d.ras

Global debug

const debug: VBA.DebugObject

VBA: Debug

Writing to the Immediate window (Debug.Print) and assertions.

Microsoft reference

vba.d.ras

Global vbCrLf

const vbCrLf: string

Carriage return and line feed (CR + LF).

Microsoft reference

vba.d.ras

Global vbCr

const vbCr: string

The carriage return character (CR).

Microsoft reference

vba.d.ras

Global vbLf

const vbLf: string

The line feed character (LF).

Microsoft reference

vba.d.ras

Global vbTab

const vbTab: string

The tab character.

Microsoft reference

vba.d.ras

Global vbNullString

const vbNullString: string

A string pointer with the value 0. Unlike the empty string "", it is used to pass NULL to DLL functions.

Microsoft reference

vba.d.ras

Global vbNullChar

const vbNullChar: string

The character with code 0.

Microsoft reference

vba.d.ras

Global vbNewLine

const vbNewLine: string

The line break of the platform (CR + LF on Windows).

Microsoft reference

vba.d.ras

Global vbBack

const vbBack: string

The backspace character.

Microsoft reference

vba.d.ras

Global vbFormFeed

const vbFormFeed: string

The form feed character.

Microsoft reference

vba.d.ras

Global vbVerticalTab

const vbVerticalTab: string

The vertical tab character.

Microsoft reference

vba.d.ras

Global vbObjectError

const vbObjectError: int

The base of user-defined error numbers (-2147221504). Make your own error numbers by adding to it.

Microsoft reference

vba.d.ras

Global dbNull

const dbNull: any

VBA: Null

VBA's Null (the value meaning there is no valid data). Use it to put Null into database fields or control values and to return Null. Check for it with isNull(v).

RAS's null becomes Empty when stored in any and Nothing for objects (not Null). v == null and v ?? x treat Empty, Nothing and Null all as "no value".

Microsoft reference

vba.d.ras

Function msgBox

function msgBox(prompt: any, buttons?: VBA.VbMsgBoxStyle, title?: any, helpFile?: any, context?: any): VBA.VbMsgBoxResult

VBA: MsgBox

Shows a message box and returns the button pressed.

Microsoft reference

vba.d.ras

Function inputBox

function inputBox(prompt: any, title?: any, defaultValue?: any, xPos?: any, yPos?: any, helpFile?: any, context?: any): string

VBA: InputBox

Shows an input dialog and returns the text entered. An empty string when canceled.

Microsoft reference

vba.d.ras

Function createObject

function createObject(className: string, serverName?: string): object

VBA: CreateObject

Creates a COM object from its ProgID.

Microsoft reference

vba.d.ras

Function getObject

function getObject(pathName?: any, className?: any): object

VBA: GetObject

Gets a COM object from a file or from a running instance.

Microsoft reference

vba.d.ras

Function shell

function shell(pathName: any, windowStyle?: VBA.VbAppWinStyle): double

VBA: Shell

Starts a program and returns its task ID. Does not wait for it to finish.

Microsoft reference

vba.d.ras

Function environ

function environ(expression: any): string

VBA: Environ

Returns the value of an environment variable.

Microsoft reference

vba.d.ras

Function command

function command(): string

VBA: Command

Returns the argument part of the command line the application was started with.

Microsoft reference

vba.d.ras

Function doEvents

function doEvents(): int

VBA: DoEvents

Yields to the OS so that pending events are processed.

Microsoft reference

vba.d.ras

Function timer

function timer(): float

VBA: Timer

Returns the number of seconds since midnight.

Microsoft reference

vba.d.ras

Function beep

function beep(): void

VBA: Beep

Sounds a beep.

Microsoft reference

vba.d.ras

Function appActivate

function appActivate(title: any, wait?: any): void

VBA: AppActivate

Activates the application window with the given title.

Microsoft reference

vba.d.ras

Function sendKeys

function sendKeys(str: string, wait?: any): void

VBA: SendKeys

Sends keystrokes to the active window.

Microsoft reference

vba.d.ras

Function saveSetting

function saveSetting(appName: string, section: string, key: string, setting: string): void

VBA: SaveSetting

Saves a setting in the application's area of the registry.

Microsoft reference

vba.d.ras

Function getSetting

function getSetting(appName: string, section: string, key: string, defaultValue?: any): string

VBA: GetSetting

Reads a setting from the application's area of the registry.

Microsoft reference

vba.d.ras

Function deleteSetting

function deleteSetting(appName: string, section?: any, key?: any): void

VBA: DeleteSetting

Deletes a section or key from the application's area of the registry.

Microsoft reference

vba.d.ras

Function callByName

function callByName(obj: object, procName: string, callType: VBA.VbCallType, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any, arg6?: any, arg7?: any, arg8?: any): any

VBA: CallByName

Calls a property or method of an object given by its name as a string.

Microsoft reference

vba.d.ras

Function iIf

function iIf(expression: any, truePart: any, falsePart: any): any

VBA: IIf

Returns the second argument if the condition is true, the third if false. Both arguments are always evaluated.

Microsoft reference

vba.d.ras

Function choose

function choose(index: float, choice1?: any, choice2?: any, choice3?: any, choice4?: any, choice5?: any, choice6?: any, choice7?: any, choice8?: any, choice9?: any, choice10?: any): any

VBA: Choose

Returns the argument for the index (1-based).

Microsoft reference

vba.d.ras

Function switch

function switch(arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any, arg6?: any, arg7?: any, arg8?: any, arg9?: any, arg10?: any): any

VBA: Switch

Checks "condition, value" pairs in order and returns the value for the first true condition.

Microsoft reference

vba.d.ras

Function isNumeric

function isNumeric(expression: cellValue): boolean

VBA: IsNumeric

Returns whether the value can be evaluated as a number.

Microsoft reference

vba.d.ras

Function isDate

function isDate(expression: cellValue): boolean

VBA: IsDate

Returns whether the value can be evaluated as a date.

Microsoft reference

vba.d.ras

Function isEmpty

function isEmpty(expression: cellValue): boolean

VBA: IsEmpty

Returns whether a Variant is uninitialized (Empty).

Microsoft reference

vba.d.ras

Function isNull

function isNull(expression: cellValue): boolean

VBA: IsNull

Returns whether the value is Null.

Microsoft reference

vba.d.ras

Function isObject

function isObject(expression: cellValue): boolean

VBA: IsObject

Returns whether the value refers to an object.

Microsoft reference

vba.d.ras

Function isArray

function isArray(varName: cellValue): boolean

VBA: IsArray

Returns whether the value is an array.

Microsoft reference

vba.d.ras

Function isError

function isError(expression: cellValue): boolean

VBA: IsError

Returns whether the value is an error value.

Microsoft reference

vba.d.ras

Function isMissing

function isMissing(argName: cellValue): boolean

VBA: IsMissing

Returns whether an optional Variant argument was omitted.

Microsoft reference

vba.d.ras

Function typeName

function typeName(varName: cellValue): string

VBA: TypeName

Returns the type name of a variable as a string.

Microsoft reference

vba.d.ras

Function varType

function varType(varName: cellValue): VBA.VbVarType

VBA: VarType

Returns a value representing the data type of a variable.

Microsoft reference

vba.d.ras

Function array

function array(...args: any[]): any

VBA: Array

Creates a Variant array of the arguments.

Microsoft reference

vba.d.ras

Function lBound

function lBound(arr: any, dimension?: int): int

VBA: LBound

Returns the lowest index of the given dimension of an array.

Microsoft reference

vba.d.ras

Function uBound

function uBound(arr: any, dimension?: int): int

VBA: UBound

Returns the highest index of the given dimension of an array. A run-time error for an empty array.

Microsoft reference

vba.d.ras

Function len

function len(s: any): int

VBA: Len

Returns the number of characters of a string, or the number of bytes needed to store a variable.

Microsoft reference

vba.d.ras

Function lenB

function lenB(s: any): int

VBA: LenB

Returns the number of bytes of a string.

Microsoft reference

vba.d.ras

Function left

function left(s: string, length: int): string

VBA: Left

Returns the given number of characters from the left of a string.

Microsoft reference

vba.d.ras

Function mid

function mid(s: string, start: int, length?: int): string

VBA: Mid

Returns the given number of characters from the given position (1-based) of a string.

Microsoft reference

vba.d.ras

Function inStr

function inStr(start: any, string1?: any, string2?: any, compare?: VBA.VbCompareMethod): int

VBA: InStr

Returns the position (1-based; 0 if not found) where string2 first appears in string1. VBA allows omitting the leading start, but this declaration has only the one form (start, string1, string2, compare). The compiler emits all four arguments.

Microsoft reference

vba.d.ras

Function inStrRev

function inStrRev(stringCheck: string, stringMatch: string, start?: int, compare?: VBA.VbCompareMethod): int

VBA: InStrRev

Searches from the end of the string and returns the position found (1-based; 0 if not found).

Microsoft reference

vba.d.ras

Function replace

function replace(expression: string, find: string, replace: string, start?: int, count?: int, compare?: VBA.VbCompareMethod): string

VBA: Replace

Replaces substrings in a string with another string.

Microsoft reference

vba.d.ras

Function trim

function trim(s: string): string

VBA: Trim

Removes leading and trailing spaces.

Microsoft reference

vba.d.ras

Function lTrim

function lTrim(s: string): string

VBA: LTrim

Removes leading spaces.

Microsoft reference

vba.d.ras

Function rTrim

function rTrim(s: string): string

VBA: RTrim

Removes trailing spaces.

Microsoft reference

vba.d.ras

Function uCase

function uCase(s: string): string

VBA: UCase

Converts to uppercase.

Microsoft reference

vba.d.ras

Function lCase

function lCase(s: string): string

VBA: LCase

Converts to lowercase.

Microsoft reference

vba.d.ras

Function strComp

function strComp(string1: any, string2: any, compare?: VBA.VbCompareMethod): int

VBA: StrComp

Compares two strings and returns -1 / 0 / 1.

Microsoft reference

vba.d.ras

Function strConv

function strConv(str: any, conversion: VBA.VbStrConv, localeId?: int): any

VBA: StrConv

Converts character types (uppercase / lowercase, full-width / half-width, hiragana / katakana, Unicode).

Microsoft reference

vba.d.ras

Function strReverse

function strReverse(expression: string): string

VBA: StrReverse

Returns the string with its characters in reverse order.

Microsoft reference

vba.d.ras

Function space

function space(number: int): string

VBA: Space

Returns a string of the given number of spaces.

Microsoft reference

vba.d.ras

Function string

function string(number: int, character: any): string

VBA: String

Returns a string of the given character repeated the given number of times.

Microsoft reference

vba.d.ras

Function split

function split(expression: string, delimiter?: any, limit?: int, compare?: VBA.VbCompareMethod): string[]

VBA: Split

Returns an array (0-based) of the strings split at the delimiter.

Microsoft reference

vba.d.ras

Function join

function join(sourceArray: any, delimiter?: any): string

VBA: Join

Returns a string of the elements of the array joined with the delimiter.

Microsoft reference

vba.d.ras

Function filter

function filter(sourceArray: any, match: string, include?: boolean, compare?: VBA.VbCompareMethod): string[]

VBA: Filter

Returns only the elements of a string array that contain (or do not contain) the given string.

Microsoft reference

vba.d.ras

Function asc

function asc(s: string): int

VBA: Asc

Returns the character code (ANSI / Shift_JIS) of the first character.

Microsoft reference

vba.d.ras

Function ascW

function ascW(s: string): int

VBA: AscW

Returns the Unicode code of the first character.

Microsoft reference

vba.d.ras

Function chr

function chr(charCode: int): string

VBA: Chr

Returns the character for a character code (ANSI / Shift_JIS).

Microsoft reference

vba.d.ras

Function chrW

function chrW(charCode: int): string

VBA: ChrW

Returns the character for a Unicode code.

Microsoft reference

vba.d.ras

Function hex

function hex(number: any): string

VBA: Hex

Converts a number to a hexadecimal string.

Microsoft reference

vba.d.ras

Function oct

function oct(number: any): string

VBA: Oct

Converts a number to an octal string.

Microsoft reference

vba.d.ras

Function str

function str(number: any): string

VBA: Str

Converts a number to a string. Positive numbers get a leading space for the sign.

Microsoft reference

vba.d.ras

Function val

function val(s: string): double

VBA: Val

Converts the leading digits of a string to a number.

Microsoft reference

vba.d.ras

Function format

function format(expression: any, format?: any, firstDayOfWeek?: VBA.VbDayOfWeek, firstWeekOfYear?: VBA.VbFirstWeekOfYear): string

VBA: Format

Formats a value as a string according to a format.

Microsoft reference

vba.d.ras

Function formatNumber

function formatNumber(expression: any, numDigitsAfterDecimal?: int, includeLeadingDigit?: VBA.VbTriState, useParensForNegativeNumbers?: VBA.VbTriState, groupDigits?: VBA.VbTriState): string

VBA: FormatNumber

Formats a number as a string with the given digit grouping and number of decimal places.

Microsoft reference

vba.d.ras

Function formatCurrency

function formatCurrency(expression: any, numDigitsAfterDecimal?: int, includeLeadingDigit?: VBA.VbTriState, useParensForNegativeNumbers?: VBA.VbTriState, groupDigits?: VBA.VbTriState): string

VBA: FormatCurrency

Formats a number as a currency string.

Microsoft reference

vba.d.ras

Function formatPercent

function formatPercent(expression: any, numDigitsAfterDecimal?: int, includeLeadingDigit?: VBA.VbTriState, useParensForNegativeNumbers?: VBA.VbTriState, groupDigits?: VBA.VbTriState): string

VBA: FormatPercent

Formats a number as a percentage string.

Microsoft reference

vba.d.ras

Function formatDateTime

function formatDateTime(expression: any, namedFormat?: VBA.VbDateTimeFormat): string

VBA: FormatDateTime

Formats a date or time as a string in a predefined format.

Microsoft reference

vba.d.ras

Function cStr

function cStr(expression: any): string

VBA: CStr

Converts to String.

Microsoft reference

vba.d.ras

Function cLng

function cLng(expression: any): int

VBA: CLng

Converts to Long (RAS's int). The fraction is rounded to even.

Microsoft reference

vba.d.ras

Function cInt

function cInt(expression: any): short

VBA: CInt

Converts to Integer (RAS's short). The fraction is rounded to even.

Microsoft reference

vba.d.ras

Function cDbl

function cDbl(expression: any): double

VBA: CDbl

Converts to Double.

Microsoft reference

vba.d.ras

Function cSng

function cSng(expression: any): float

VBA: CSng

Converts to Single (RAS's float).

Microsoft reference

vba.d.ras

Function cBool

function cBool(expression: any): boolean

VBA: CBool

Converts to Boolean.

Microsoft reference

vba.d.ras

Function cDate

function cDate(expression: any): date

VBA: CDate

Converts to Date.

Microsoft reference

vba.d.ras

Function cCur

function cCur(expression: any): currency

VBA: CCur

Converts to Currency.

Microsoft reference

vba.d.ras

Function cDec

function cDec(expression: any): decimal

VBA: CDec

Converts to Decimal.

Microsoft reference

vba.d.ras

Function cByte

function cByte(expression: any): byte

VBA: CByte

Converts to Byte.

Microsoft reference

vba.d.ras

Function cVar

function cVar(expression: any): any

VBA: CVar

Converts to Variant.

Microsoft reference

vba.d.ras

Function cLngLng

function cLngLng(expression: any): long

VBA: CLngLng

Converts to LongLong (RAS's long). 64-bit Office only.

Microsoft reference

vba.d.ras

Function cLngPtr

function cLngPtr(expression: any): ptr

VBA: CLngPtr

Converts to LongPtr (RAS's ptr).

Microsoft reference

vba.d.ras

Function cvErr

function cvErr(expression: any): cellValue

VBA: CVErr

Returns an error value (Variant) with the given error number.

Microsoft reference

vba.d.ras

Function abs

function abs(number: any): any

VBA: Abs

Returns the absolute value.

Microsoft reference

vba.d.ras

Function sgn

function sgn(number: any): int

VBA: Sgn

Returns the sign as -1 / 0 / 1.

Microsoft reference

vba.d.ras

Function sqr

function sqr(number: double): double

VBA: Sqr

Returns the square root.

Microsoft reference

vba.d.ras

Function int

function int(number: any): any

VBA: Int

Returns the integer part without the fraction. For negative numbers, the next lower integer.

Microsoft reference

vba.d.ras

Function fix

function fix(number: any): any

VBA: Fix

Returns the integer part without the fraction. For negative numbers, the integer closer to 0.

Microsoft reference

vba.d.ras

Function round

function round(number: any, numDigitsAfterDecimal?: int): any

VBA: Round

Rounds to the given number of decimal places. An exact half is rounded to even (banker's rounding).

Microsoft reference

vba.d.ras

Function exp

function exp(number: double): double

VBA: Exp

Returns e raised to a power.

Microsoft reference

vba.d.ras

Function log

function log(number: double): double

VBA: Log

Returns the natural logarithm.

Microsoft reference

vba.d.ras

Function sin

function sin(number: double): double

VBA: Sin

Returns the sine. The angle is in radians.

Microsoft reference

vba.d.ras

Function cos

function cos(number: double): double

VBA: Cos

Returns the cosine. The angle is in radians.

Microsoft reference

vba.d.ras

Function tan

function tan(number: double): double

VBA: Tan

Returns the tangent. The angle is in radians.

Microsoft reference

vba.d.ras

Function atn

function atn(number: double): double

VBA: Atn

Returns the arctangent in radians.

Microsoft reference

vba.d.ras

Function rnd

function rnd(number?: any): float

VBA: Rnd

Returns a random number from 0 up to (but not including) 1.

Microsoft reference

vba.d.ras

Function randomize

function randomize(number?: any): void

VBA: Randomize

Initializes the random number generator.

Microsoft reference

vba.d.ras

Function rgb

function rgb(red: int, green: int, blue: int): int

VBA: RGB

Makes an RGB value from red, green and blue components (0 to 255).

Microsoft reference

vba.d.ras

Function qbColor

function qbColor(color: int): int

VBA: QBColor

Returns the RGB value for a color number (0 to 15).

Microsoft reference

vba.d.ras

Function now

function now(): date

VBA: Now

Returns the current date and time.

Microsoft reference

vba.d.ras

Function date

function date(): date

VBA: Date

Returns the current date.

Microsoft reference

vba.d.ras

Function time

function time(): date

VBA: Time

Returns the current time.

Microsoft reference

vba.d.ras

Function dateSerial

function dateSerial(year: int, month: int, day: int): date

VBA: DateSerial

Makes a date from a year, month and day.

Microsoft reference

vba.d.ras

Function timeSerial

function timeSerial(hour: int, minute: int, second: int): date

VBA: TimeSerial

Makes a time from hours, minutes and seconds.

Microsoft reference

vba.d.ras

Function dateValue

function dateValue(dateString: string): date

VBA: DateValue

Converts a string representing a date to a date.

Microsoft reference

vba.d.ras

Function timeValue

function timeValue(timeString: string): date

VBA: TimeValue

Converts a string representing a time to a time.

Microsoft reference

vba.d.ras

Function dateAdd

function dateAdd(interval: string, number: double, dateValue: any): date

VBA: DateAdd

Returns the date with a time interval of the given unit added.

Microsoft reference

vba.d.ras

Function dateDiff

function dateDiff(interval: string, date1: any, date2: any, firstDayOfWeek?: VBA.VbDayOfWeek, firstWeekOfYear?: VBA.VbFirstWeekOfYear): int

VBA: DateDiff

Returns the interval between two dates, counted in the given unit.

Microsoft reference

vba.d.ras

Function datePart

function datePart(interval: string, dateValue: any, firstDayOfWeek?: VBA.VbDayOfWeek, firstWeekOfYear?: VBA.VbFirstWeekOfYear): int

VBA: DatePart

Returns the value of the given unit (year, quarter, week and so on) of a date.

Microsoft reference

vba.d.ras

Function year

function year(dateValue: any): int

VBA: Year

Returns the year of a date.

Microsoft reference

vba.d.ras

Function month

function month(dateValue: any): int

VBA: Month

Returns the month of a date (1 to 12).

Microsoft reference

vba.d.ras

Function day

function day(dateValue: any): int

VBA: Day

Returns the day of a date (1 to 31).

Microsoft reference

vba.d.ras

Function hour

function hour(timeValue: any): int

VBA: Hour

Returns the hour of a time (0 to 23).

Microsoft reference

vba.d.ras

Function minute

function minute(timeValue: any): int

VBA: Minute

Returns the minute of a time (0 to 59).

Microsoft reference

vba.d.ras

Function second

function second(timeValue: any): int

VBA: Second

Returns the second of a time (0 to 59).

Microsoft reference

vba.d.ras

Function weekday

function weekday(dateValue: any, firstDayOfWeek?: VBA.VbDayOfWeek): int

VBA: Weekday

Returns the day of the week of a date as a number (Sunday is 1 by default).

Microsoft reference

vba.d.ras

Function weekdayName

function weekdayName(weekday: int, abbreviate?: boolean, firstDayOfWeek?: VBA.VbDayOfWeek): string

VBA: WeekdayName

Returns the name of the day of the week for a weekday number.

Microsoft reference

vba.d.ras

Function monthName

function monthName(month: int, abbreviate?: boolean): string

VBA: MonthName

Returns the name of the month for a month number.

Microsoft reference

vba.d.ras

Function dir

function dir(pathName?: any, attributes?: VBA.VbFileAttribute): string

VBA: Dir

Returns a file name matching the pattern and attributes. Called without arguments, it returns the next match, and an empty string when there are no more.

Microsoft reference

vba.d.ras

Function kill

function kill(pathName: any): void

VBA: Kill

Deletes files. Wildcards can be used.

Microsoft reference

vba.d.ras

Function fileCopy

function fileCopy(source: string, destination: string): void

VBA: FileCopy

Copies a file.

Microsoft reference

vba.d.ras

Function fileLen

function fileLen(pathName: string): int

VBA: FileLen

Returns the size of a file (bytes).

Microsoft reference

vba.d.ras

Function fileDateTime

function fileDateTime(pathName: string): date

VBA: FileDateTime

Returns when a file was created or last modified.

Microsoft reference

vba.d.ras

Function getAttr

function getAttr(pathName: string): VBA.VbFileAttribute

VBA: GetAttr

Returns the attributes of a file or folder.

Microsoft reference

vba.d.ras

Function setAttr

function setAttr(pathName: string, attributes: VBA.VbFileAttribute): void

VBA: SetAttr

Sets the attributes of a file.

Microsoft reference

vba.d.ras

Function mkDir

function mkDir(path: string): void

VBA: MkDir

Creates a folder.

Microsoft reference

vba.d.ras

Function rmDir

function rmDir(path: string): void

VBA: RmDir

Deletes an empty folder.

Microsoft reference

vba.d.ras

Function chDir

function chDir(path: string): void

VBA: ChDir

Changes the current folder.

Microsoft reference

vba.d.ras

Function chDrive

function chDrive(drive: string): void

VBA: ChDrive

Changes the current drive.

Microsoft reference

vba.d.ras

Function curDir

function curDir(drive?: any): string

VBA: CurDir

Returns the path of the current folder.

Microsoft reference

vba.d.ras

Function freeFile

function freeFile(rangeNumber?: any): int

VBA: FreeFile

Returns the next available file number.

Microsoft reference

vba.d.ras

Function eof

function eof(fileNumber: int): boolean

VBA: EOF

Returns whether the end of an open file has been reached.

Microsoft reference

vba.d.ras

Function lof

function lof(fileNumber: int): int

VBA: LOF

Returns the size of an open file (bytes).

Microsoft reference

vba.d.ras

Function loc

function loc(fileNumber: int): int

VBA: Loc

Returns the current position in an open file (for forRandom, the number of the last record read or written; for forBinary, the position of the last byte read or written; for text modes, the byte position ÷ 128).

Microsoft reference

vba.d.ras

Function fileAttr

function fileAttr(fileNumber: int, returnType?: int): int

VBA: FileAttr

Returns the mode of an open file (when returnType is 1; a value of FileIO.OpenMode).

Microsoft reference

vba.d.ras

Function objPtr

function objPtr(obj: any): ptr

VBA: ObjPtr

Returns the interface pointer of an object.

Microsoft reference

vba.d.ras

Function strPtr

function strPtr(s: string): ptr

VBA: StrPtr

Returns the address of a string buffer (BSTR).

Microsoft reference

vba.d.ras

Function varPtr

function varPtr(v: any): ptr

VBA: VarPtr

Returns the address of a variable.

Microsoft reference

vba.d.ras