📄 vba_functions.html
字号:
<html><!-- == $Id: //open/mondrian-release/3.0/doc/vba_functions.html#2 $ == This software is subject to the terms of the Common Public License == Agreement, available at the following URL: == http://www.opensource.org/licenses/cpl.html. == Copyright (C) 2008-2008 Julian Hyde == All Rights Reserved. == You must accept the terms of that agreement to use this software. --><head> <link rel="stylesheet" type="text/css" href="stylesheet.css"/> <title>Pentaho Analysis Services: Visual Basic for Applications (VBA) Functions</title></head><body><!-- doc2web start --><!-- page title --><div class="contentheading">Visual Basic for Applications (VBA) Function List</div><!-- end page title --><p>The following table describes the functions in the Visual Basic for Applications (VBA) specification, which are implicitly part of the MDX language specification.</p><p>Some of the functions are not implemented in mondrian, but are included for completeness. The 'Mondrian version/priority' column indicates which functions are implemented in mondrian, and if not, priority of the development team for adding them. Some functions, such as Beep, will never be implemented in Mondrian MDX.</p><p>The MDX language implemented by mondrian, including a list of set of functions implemented, is described in the <a href="mdx.html">MDX specification</a>.</p><table style="border-collapse: collapse" border="1" width="500"><tr><th>Name</th><th>Description</th><th>Mondrian version / priority</th></tr><tr><td>Abs</td><td>Returns a value of the same type that is passed to it specifying the absolute value of a number.<br> <br> Syntax<br> <br> Abs(number)<br> <br> The required number argument can be any valid numeric expression. If number contains Null, Null is returned; if it is an uninitialized variable, zero is returned.<br> <br> Remarks<br> <br> The absolute value of a number is its unsigned magnitude. For example, ABS(-1) and ABS(1) both return 1.</td><td>1</td></tr><tr><td>Add</td><td></td><td>-</td></tr><tr><td>AppActivate</td><td></td><td>-</td></tr><tr><td>Array</td><td>Returns a Variant containing an array.<br> <br> Syntax<br> <br> Array(arglist)<br> <br> The required arglist argument is a comma-delimited list of values that are assigned to the elements of the array contained within the Variant. If no arguments are specified, an array of zero length is created.<br> <br> Remarks<br> <br> The notation used to refer to an element of an array consists of the variable name followed by parentheses containing an index number indicating the desired element. In the following example, the first statement creates a variable named <br> A<br> as a Variant. The second statement assigns an array to variable <br> A<br> . The last statement assigns the value contained in the second array element to another variable.<br> <br> Dim A As Variant<br> A = Array(10,20,30)<br> B = A(2)<br> The lower bound of an array created using the Array function is determined by the lower bound specified with the Option Base statement, unless Array is qualified with the name of the type library (for example VBA.Array). If qualified with the type-library name, Array is unaffected by Option Base.<br> <br> Note A Variant that is not declared as an array can still contain an array. A Variant variable can contain an array of any type, except fixed-length strings and user-defined types. Although a Variant containing an array is conceptually different from an array whose elements are of type Variant, the array elements are accessed in the same way.</td><td>Not applicable - mondrian has no array data type</td></tr><tr><td>Asc</td><td>Returns an Integer representing the character code corresponding to the first letter in a string.<br> <br> Syntax<br> <br> Asc(string)<br> <br> The required string argument is any valid string expression. If the string contains no characters, a run-time error occurs.<br> <br> Remarks<br> <br> The range for returns is 0 255 on non-DBCS systems, but 32768 32767 on DBCS systems.<br> <br> Note The AscB function is used with byte data contained in a string. Instead of returning the character code for the first character, AscB returns the first byte. The AscW function returns the Unicode character code except on platforms where Unicode is not supported, in which case, the behavior is identical to the Asc function.</td><td>1</td></tr><tr><td>AscB</td><td>See Asc</td><td>N/A</td></tr><tr><td>AscW</td><td>See Asc</td><td>1</td></tr><tr><td>Atn</td><td>Returns a Double specifying the arctangent of a number.<br> <br> Syntax<br> <br> Atn(number)<br> <br> The required number argument is a Double or any valid numeric expression.<br> <br> Remarks<br> <br> The Atn function takes the ratio of two sides of a right triangle (number) and returns the corresponding angle in radians. The ratio is the length of the side opposite the angle divided by the length of the side adjacent to the angle.<br> <br> The range of the result is -pi/2 to pi/2 radians.<br> <br> To convert degrees to radians, multiply degrees by pi/180. To convert radians to degrees, multiply radians by 180/pi.<br> <br> Note Atn is the inverse trigonometric function of Tan, which takes an angle as its argument and returns the ratio of two sides of a right triangle. Do not confuse Atn with the cotangent, which is the simple inverse of a tangent (1/tangent).</td><td>1</td></tr><tr><td>Beep</td><td></td><td>Not applicable in server</td></tr><tr><td>Calendar</td><td></td><td>-</td></tr><tr><td>CallByName</td><td>Executes a method of an object, or sets or returns a property of an object.<br> <br> Syntax<br> <br> CallByName(object, procname, calltype,[args()])<br> <br> The CallByName function syntax has these named arguments:<br> <br> Part Description <br> object Required; Variant (Object). The name of the object on which the function will be executed. <br> procname Required; Variant (String). A string expression containing the name of a property or method of the object. <br> calltype Required; Constant. A constant of type vbCallType representing the type of procedure being called. <br> args() Optional: Variant (Array). <br> <br> Remarks<br> <br> The CallByName function is used to get or set a property, or invoke a method at run time using a string name.<br> <br> In the following example, the first line uses CallByName to set the MousePointer property of a text box, the second line gets the value of the MousePointer property, and the third line invokes the Move method to move the text box:<br> <br> CallByName Text1, "MousePointer", vbLet, vbCrosshair<br> Result = CallByName (Text1, "MousePointer", vbGet)<br> CallByName Text1, "Move", vbMethod, 100, 100</td><td>-</td></tr><tr><td>CBool</td><td>Returns an expression that has been converted to a Variant of subtype Boolean.<br> <br> CBool(expression)<br> <br> The expression argument is any valid expression.<br> <br> If expression is zero, False is returned; otherwise, True is returned. If expression can't be interpreted as a numeric value, a run-time error occurs.<br> <br> The following example uses the CBool function to convert an expression to a Boolean. If the expression evaluates to a nonzero value, CBool returns True; otherwise, it returns False. </td><td>2</td></tr><tr><td>CByte</td><td>Returns an expression that has been converted to a Variant of subtype Byte.<br> <br> CByte(expression)<br> <br> The expression argument is any valid expression.<br> <br> In general, you can document your code using the subtype conversion functions to show that the result of some operation should be expressed as a particular data type rather than the default data type. For example, use CByte to force byte arithmetic in cases where currency, single-precision, double-precision, or integer arithmetic normally would occur.<br> <br> Use the CByte function to provide internationally aware conversions from any other data type to a Byte subtype. For example, different decimal separators are properly recognized depending on the locale setting of your system, as are different thousand separators.<br> <br> If expression lies outside the acceptable range for the byte subtype, an error occurs.</td><td>N/A; mondrian has no byte datatype</td></tr><tr><td>CCur</td><td>Returns an expression that has been converted to a Variant of subtype Currency.<br> <br> CCur(expression)<br> <br> The expression argument is any valid expression.<br> <br> In general, you can document your code using the subtype conversion functions to show that the result of some operation should be expressed as a particular data type rather than the default data type. For example, use CCur to force currency arithmetic in cases where integer arithmetic normally would occur.<br> <br> You should use the CCur function to provide internationally aware conversions from any other data type to a Currency subtype. For example, different decimal separators and thousands separators are properly recognized depending on the locale setting of your system.</td><td>-</td></tr><tr><td>CDate</td><td>Returns an expression that has been converted to a Variant of subtype Date.<br> <br> CDate(date)<br> <br> The date argument is any valid date expression.<br> <br> Use the IsDate function to determine if date can be converted to a date or time. CDate recognizes date literals and time literals as well as some numbers that fall within the range of acceptable dates. When converting a number to a date, the whole number portion is converted to a date. Any fractional part of the number is converted to a time of day, starting at midnight.<br> <br> CDate recognizes date formats according to the locale setting of your system. The correct order of day, month, and year may not be determined if it is provided in a format other than one of the recognized date settings. In addition, a long date format is not recognized if it also contains the day-of-the-week string.</td><td>1</td></tr><tr><td>CDbl</td><td>Returns an expression that has been converted to a Variant of subtype Double.<br> <br> CDbl(expression)<br> <br> The expression argument is any valid expression.<br> <br> In general, you can document your code using the subtype conversion functions to show that the result of some operation should be expressed as a particular data type rather than the default data type. For example, use CDbl or CSng to force double-precision or single-precision arithmetic in cases where currency or integer arithmetic normally would occur.<br> <br> Use the CDbl function to provide internationally aware conversions from any other data type to a Double subtype. For example, different decimal separators and thousands separators are properly recognized depending on the locale setting of your system.</td><td>2</td></tr><tr><td>CDec</td><td> </td><td> </td></tr><tr><td>ChDir</td><td> </td><td> </td></tr><tr><td>ChDrive</td><td> </td><td> </td></tr><tr><td>Choose</td><td> </td><td> </td></tr><tr><td>Chr</td><td>Returns a String containing the character associated with the specified character code.<br> <br> Syntax<br> <br> Chr(charcode)<br> <br> The required charcode argument is a Long that identifies a character.<br> <br> Remarks<br> <br> Numbers from 0 31 are the same as standard, nonprintable ASCII codes. For example, Chr(10) returns a linefeed character. The normal range for charcode is 0 255. However, on DBCS systems, the actual range for charcode is -32768 to 65535.<br> <br> Note The ChrB function is used with byte data contained in a String. Instead of returning a character, which may be one or two bytes, ChrB always returns a single byte. The ChrW function returns a String containing the Unicode character except on platforms where Unicode is not supported, in which case, the behavior is identical to the Chr function.</td><td>1</td></tr><tr><td>ChrB</td><td>See Chr.</td><td>-</td></tr><tr><td>ChrW</td><td>See Chr.</td><td>1</td></tr><tr><td>CInt</td><td>Returns an expression that has been converted to a Variant of subtype Integer.<br> <br> CInt(expression)<br> <br> The expression argument is any valid expression.<br> <br> In general, you can document your code using the subtype conversion functions to show that the result of some operation should be expressed as a particular data type rather than the default data type. For example, use CInt or CLng to force integer arithmetic in cases where currency, single-precision, or double-precision arithmetic normally would occur.<br> <br> Use the CInt function to provide internationally aware conversions from any other data type to an Integer subtype. For example, different decimal separators are properly recognized depending on the locale setting of your system, as are different thousand separators.<br> <br> If expression lies outside the acceptable range for the Integer subtype, an error occurs.<br> <br> The following example uses the CInt function to convert a value to an Integer: <br> <br> Dim MyDouble, MyInt<br> MyDouble = 2345.5678 ' MyDouble is a Double.<br> MyInt = CInt(MyDouble) ' MyInt contains 2346.<p>Note. CInt differs from the Fix and Int functions, which truncate, rather than round, the fractional part of a number. When the fractional part is exactly 0.5, the CInt function always rounds it to the nearest even number. For example, 0.5 rounds to 0, and 1.5 rounds to 2.</td><td>2</td></tr><tr><td>Clear</td><td> </td><td> </td></tr><tr><td>CLng</td><td>Returns an expression that has been converted to a Variant of subtype Long.<br> <br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -