📄 vba_functions.html
字号:
the environment string in the environment-string table. The number argument can be any numeric expression, but is rounded to a whole number before it is evaluated. <br> <br> <br> Remarks<br> <br> If envstring can't be found in the environment-string table, a zero-length string ("") is returned. Otherwise, Environ returns the text assigned to the specified envstring; that is, the text following the equal sign (=) in the environment-string table for that environment variable.<br> <br> If you specify number, the string occupying that numeric position in the environment-string table is returned. In this case, Environ returns all of the text, including envstring. If there is no environment string in the specified position, Environ returns a zero-length string.</td><td>-</td></tr><tr><td>EOF</td><td>Returns an Integer containing the Boolean value True when the end of a file opened for Random or sequential Input has been reached.<br> <br> Syntax<br> <br> EOF(filenumber)<br> <br> The required filenumber argument is an Integer containing any valid file number.<br> <br> Remarks<br> <br> Use EOF to avoid the error generated by attempting to get input past the end of a file.<br> <br> The EOF function returns False until the end of the file has been reached. With files opened for Random or Binary access, EOF returns False until the last executed Get statement is unable to read an entire record.<br> <br> With files opened for Binary access, an attempt to read through the file using the Input function until EOF returns True generates an error. Use the LOF and Loc functions instead of EOF when reading binary files with Input, or use Get when using the EOF function. With files opened for Output, EOF always returns True.</td><td>-</td></tr><tr><td>Err</td><td>Contains information about run-time errors.<br> <br> Remarks<br> The properties of the Err object are set by the generator of an error Visual Basic, an object, or the programmer.<br> <br> The default property of the Err object is Number. Because the default property can be represented by the object name Err, earlier code written using the Err function or Err statement doesn't have to be modified.<br> <br> When a run-time error occurs, the properties of the Err object are filled with information that uniquely identifies the error and information that can be used to handle it. To generate a run-time error in your code, use the Raise method.<br> <br> The Err object's properties are reset to zero or zero-length strings ("") after an Exit Sub, Exit Function, Exit Property or Resume Next statement within an error-handling routine. Using any form of the Resume statement outside of an error-handling routine will not reset the Err object's properties. The Clear method can be used to explicitly reset Err.<br> <br> Use the Raise method, rather than the Error statement, to generate run-time errors for system errors and class modules. Using the Raise method in other code depends on the richness of the information you want to return.<br> <br> The Err object is an intrinsic object with global scope. There is no need to create an instance of it in your code.</td><td> </td></tr><tr><td>Error</td><td>Returns the error message that corresponds to a given error number.<br> <br> Syntax<br> <br> Error[(errornumber)]<br> <br> The optional errornumber argument can be any valid error number. If errornumber is a valid error number, but is not defined, Error returns the string "Application-defined or object-defined error." If errornumber is not valid, an error occurs. If errornumber is omitted, the message corresponding to the most recent run-time error is returned. If no run-time error has occurred, or errornumber is 0, Error returns a zero-length string ("").<br> <br> Remarks<br> <br> Examine the property settings of the Err object to identify the most recent run-time error. The return value of the Error function corresponds to the Description property of the Err object.</td><td>-</td></tr><tr><td>Exp</td><td>Returns a Double specifying e (the base of natural logarithms) raised to a power.<br> <br> Syntax<br> <br> Exp(number)<br> <br> The required number argument is a Double or any valid numeric expression.<br> <br> Remarks<br> <br> If the value of number exceeds 709.782712893, an error occurs. The constant e is approximately 2.718282.<br> <br> Note The Exp function complements the action of the Log function and is sometimes referred to as the antilogarithm.</td><td>1</td></tr><tr><td>FileAttr</td><td>Returns a Long representing the file mode for files opened using the Open statement.<br> <br> Syntax<br> <br> FileAttr(filenumber, returntype)<br> <br> The FileAttr function syntax has these named arguments:<br> <br> Part Description <br> filenumber Required; Integer. Any valid file number. <br> returntype Required; Integer. Number indicating the type of information to return. Specify 1 to return a value indicating the file mode. On 16-bit systems only, specify 2 to retrieve an operating system file handle. Returntype 2 is not supported in 32-bit systems and causes an error. <br> <br> <br> Return Values<br> <br> When the returntype argument is 1, the following return values indicate the file access mode:<br> <br> Mode Value <br> Input 1 <br> Output 2 <br> Random 4 <br> Append 8 <br> Binary 32</td><td>-</td></tr><tr><td>FileCopy</td><td> </td><td>-</td></tr><tr><td>FileDateTime</td><td>Returns a Variant (Date) that indicates the date and time when a file was created or last modified.<br> <br> Syntax<br> <br> FileDateTime(pathname)<br> <br> The required pathname argument is a string expression that specifies a file name. The pathname may include the directory or folder, and the drive.</td><td> -</td></tr><tr><td>FileLen</td><td>Returns a Long specifying the length of a file in bytes.<br> <br> Syntax<br> <br> FileLen(pathname)<br> <br> The required pathname argument is a string expression that specifies a file. The pathname may include the directory or folder, and the drive.<br> <br> Remarks<br> <br> If the specified file is open when the FileLen function is called, the value returned represents the size of the file immediately before it was opened.<br> <br> Note To obtain the length of an open file, use the LOF function.</td><td>-</td></tr><tr><td>Filter</td><td>Returns a zero-based array containing subset of a string array based on a specified filter criteria.<br> <br> Syntax<br> <br> Filter(sourcesrray, match[, include[, compare]])<br> <br> The Filter function syntax has these named argument:<br> <br> Part Description <br> sourcearray Required. One-dimensional array of strings to be searched. <br> match Required. String to search for. <br> include Optional. Boolean value indicating whether to return substrings that include or exclude match. If include is True, Filter returns the subset of the array that contains match as a substring. If include is False, Filter returns the subset of the array that does not contain match as a substring. <br> compare Optional. Numeric value indicating the kind of string comparison to use. See Settings section for values. <br> <br> <br> Settings<br> <br> The compare argument can have the following values:<br> <br> Constant Value Description <br> vbUseCompareOption 1 Performs a comparison using the setting of the Option Compare statement. <br> vbBinaryCompare 0 Performs a binary comparison. <br> vbTextCompare 1 Performs a textual comparison. <br> vbDatabaseCompare 2 Microsoft Access only. Performs a comparison based on information in your database. <br> <br> <br> Remarks<br> <br> If no matches of match are found within sourcearray, Filter returns an empty array. An error occurs if sourcearray is Null or is not a one-dimensional array.<br> <br> The array returned by the Filter function contains only enough elements to contain the number of matched items.</td><td>?</td></tr><tr><td>Fix</td><td>See Int</td><td>1</td></tr><tr><td>Format</td><td>Returns a Variant (String) containing an expression formatted according to instructions contained in a format expression.<br> <br> Syntax<br> <br> Format(expression[, format[, firstdayofweek[, firstweekofyear]]])<br> <br> The Format function syntax has these parts:<br> <br> Part Description <br> expression Required. Any valid expression. <br> format Optional. A valid named or user-defined format expression. <br> firstdayofweek Optional. A constant that specifies the first day of the week. <br> firstweekofyear Optional. A constant that specifies the first week of the year. <br> <br> <br> Settings<br> <br> The firstdayofweek argument has these settings:<br> <br> Constant Value Description <br> vbUseSystem 0 Use NLS API setting. <br> VbSunday 1 Sunday (default) <br> vbMonday 2 Monday <br> vbTuesday 3 Tuesday <br> vbWednesday 4 Wednesday <br> vbThursday 5 Thursday <br> vbFriday 6 Friday <br> vbSaturday 7 Saturday <br> <br> <br> The firstweekofyear argument has these settings:<br> <br> Constant Value Description <br> vbUseSystem 0 Use NLS API setting. <br> vbFirstJan1 1 Start with week in which January 1 occurs (default). <br> vbFirstFourDays 2 Start with the first week that has at least four days in the year. <br> vbFirstFullWeek 3 Start with the first full week of the year. <br> <br> <br> Remarks<br> <br> To Format Do This <br> Numbers Use predefined named numeric formats or create user-defined numeric formats. <br> Dates and times Use predefined named date/time formats or create user-defined date/time formats. <br> Date and time serial numbers Use date and time formats or numeric formats. <br> Strings Create your own user-defined string formats. <br> <br> <br> If you try to format a number without specifying format, Format provides functionality similar to the Str function, although it is internationally aware. However, positive numbers formatted as strings using Format dont include a leading space reserved for the sign of the value; those converted using Str retain the leading space.<br> <br> If you are formatting a non-localized numeric string, you should use a user-defined numeric format to ensure that you get the look you want.<br> <br> Note If the Calendar property setting is Gregorian and format specifies date formatting, the supplied expression must be Gregorian. If the Visual Basic Calendar property setting is Hijri, the supplied expression must be Hijri.<br> <br> If the calendar is Gregorian, the meaning of format expression symbols is unchanged. If the calendar is Hijri, all date format symbols (for example, dddd, mmmm, yyyy) have the same meaning but apply to the Hijri calendar. Format symbols remain in English; symbols that result in text display (for example, AM and PM) display the string (English or Arabic) associated with that symbol. The range of certain symbols changes when the calendar is Hijri.<br> <br> Symbol Range <br> d 1-30 <br> dd 1-30 <br> ww 1-51 <br> mmm Displays full month names (Hijri month names have no abbreviations). <br> y 1-355 <br> yyyy 100-9666 </td><td>?</td></tr><tr><td>FormatCurrency</td><td>Returns an expression formatted as a currency value using the currency symbol defined in the system control panel.<br> <br> Syntax<br> <br> FormatCurrency(Expression[,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]])<br> <br> The FormatCurrency function syntax has these parts:<br> <br> Part Description <br> Expression Required. Expression to be formatted. <br> NumDigitsAfterDecimal Optional. Numeric value indicating how many places to the right of the decimal are displayed. Default value is 1, which indicates that the computer's regional settings are used. <br> IncludeLeadingDigit Optional. Tristate constant that indicates whether or not a leading zero is displayed for fractional values. See Settings section for values. <br> UseParensForNegativeNumbers Optional. Tristate constant that indicates whether or not to place negative values within parentheses. See Settings section for values. <br> GroupDigits Optional. Tristate constant that indicates whether or not numbers are grouped using the group delimiter specified in the computer's regional settings. See Settings section for values. <br> <br> <br> Settings<br> <br> The IncludeLeadingDigit, UseParensForNegativeNumbers, and GroupDigits arguments have the following settings:<br> <br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -