Visual Basic provides more than 200 built-in statements and functions. Some are used frequently; some are seldom used at all. Even experienced programmers sometimes happen upon a statement or function they didn't know about.
This appendix can be considered a quick-reference guide to all of VB's built-in statements and functions. It offers the syntax for each, as well as a brief description of what it does and how its arguments (if any) are used. This is by no means a complete reference. Microsoft's Visual Basic 6.0 Language Reference is probably the best source for in-depth information on VB's statements and functions. If you have any questions about syntax or use of a particular statement or function, then you are strongly urged to consult that reference to obtain additional information.
Functions and Statements
Abs Function
Abs(number)
Returns the absolute value of number. The data type returned is the same as the data type of the number argument.
AppActivate Statement
AppActivate title[,wait]
Activates the application window that has the string title in its title bar or, alternatively, the task ID specified by title. The optional wait argument (Boolean) can be used to specify whether the calling application should wait until it has the focus before the application window is activated.
Array Function
Array(arglist)
Returns a Variant data item that contains an array. arglist refers to a comma-delimited list of values that make up the elements of the array, with the first value corresponding to the first element of the array, the second value corresponding to the second element of the array, and so on.
Asc Function
Asc(string)
Returns an Integer value that represents the ASCII code for the first character in the string.
Atn Function
Atn(number)
Returns a Double value that is the arctangent of number.
Beep Statement
Beep
Sounds a tone through the PC's speaker. Frequency and duration of the tone may vary from system to system.
Call Statement
[Call] name [argumentlist]
Executes a sub, function, or DLL procedure. The name argument specifies the name of the procedure to call, and argumentlist is an optional list of arguments that will be passed to the called procedure. The Call keyword is optional, but if it is included, then at least one or more arguments for argumentlist must also be included.
CBool Function
CBool(expression)
Converts the value of expression to a Boolean data type. The argument expression can be any valid string or numeric expression.
CByte Function
CByte(expression)
Converts the value of expression to a Byte data type. The argument expression must be a numeric value between 0 and 255.
CCur Function
CCur(expression)
Converts the value of expression to a Currency data type. The argument expression must be a numeric value between -922,337,203,685,477.5808 and 922,337,203,685,477.5807.
CDate Function
CDate(expression)
Converts the value of expression to a Date data type. The argument expression must be a valid date expression.
CDbl Function
CDbl(expression)
Converts the value of expression to a Double data type. The argument expression must be a numeric value between -1.79769313486232E308 and -4.94065645841247E-324 for negative values, or between 4.94065645841247E-324 and 1.79769313486232E308 for positive values.
CDec Function
CDec(expression)
Converts the value of expression to a Decimal data type. The argument expression must be a numeric value of +/-79,228,162,514,264,337,593,543,950,335 for zero-scaled numbers (numbers with no decimal places), or +/-7.9228162514264337593543950335 for numbers with 28 decimal places.
ChDir Statement
ChDir path
Changes the current directory to the one specified by the path argument. Note that although ChDir changes the default directory, it does not change the default drive as well.
ChDrive Statement
ChDrive drive
Changes the current drive to the one specified by the drive argument.
Choose Function
Choose(index, choice-1[, choice-2, ... [, choice-n]])
Returns a value from a list of choices (specified by the arguments choice-1 through choice-n) based on the value of the index argument. If index is 1, then the value returned by the Choose function will be the value represented by choice-1; if index is 2, then the value returned will be that of choice-2; and so on.
Chr Function
Chr(charcode)
Returns a one-character String value that represents the ASCII character of the number specified by the charcode argument.
CInt Function
CInt(expression)
Converts the value of expression to an Integer data type. The argument expression must be a numeric value from -32,768 to 32,767. Fractions are rounded.
CLng Function
CLng(expression)
Converts the value of expression to a Long data type. The argument expression must be a numeric value from -2,147,483,648 to 2,147,483,647. Fractions are rounded.
Close Statement
Close [filenumberlist]
Closes any files opened with the Open statement that corre- spond to the file numbers specified by filenumberlist. The filenumberlist argument can contain a single file number (for example, #1) or multiple file numbers (for example, #1, #4, #5). If the filenumberlist argument is omitted, all open files will be closed.
Command Function
Command
Returns any command-line arguments specified when launching Visual Basic. For compiled programs, Command returns the command-line arguments specified when the program was launched.
Const Statement
[Public | Private] Const constname [As type] = expression
Declares a constant with the name constname and the value represented by expression. The Public and Private keywords define the constant's scope, and the optional As type specifies the constant's data type. If the As type is omitted, the constant will be declared as the data type most appropriate for expression.
Cos Function
Cos(number)
Returns a Double value that is the cosine of the angle specified by the number argument.
CreateObject Function
CreateObject(class)
Creates and returns a reference to an ActiveX object of type class. The class argument should use the syntax appname.objecttype, where appname is the name of the application providing the object, and objecttype is the class of the object to be created.
CSng Function
CSng(expression)
Converts the value of expression to a Single data type. The argument expression must be a numeric value from -3.402823E38 to -1.401298E-45 for negative values, or from 1.401298E-45 to 3.402823E38 for positive values.
CStr Function
CStr(expression)
Converts the value of expression to a String data type. The string that CStr returns depends on the data type of the expression argument: For Booleans, CStr returns either True or False; for Dates, CStr returns a date based on the short date format on your system; for Errors, CStr returns the word Error followed by the error number. expression values that are Empty return a zero-length string, and numeric expression values return a string containing the number. A Null expression value will cause a runtime error.
CurDir Function
CurDir[(drive)]
Returns a String value that represents the full path of the current directory. If the drive argument is given, then CurDir returns the directory path of the current directory for that drive.
CVar Function
CVar(expression)
Converts the value of expression to a Variant data type. The argument expression can be either numeric or a string.
CVErr Function
CVErr(errornumber)
Returns a Variant of subtype Error that contains the error number specified by the errornumber argument.
to be continued.............
No comments:
Post a Comment