(1) Type conversion function
1. CType(X)
[Format]:
P=CBool(X )
' Convert X to "Boolean" type
P=CByte(X)
' Convert X to "Byte" ( Byte) type
P=CCur(X)
' Convert X to "Amount" (Currency) type
P=CDate(X)
p>' Convert X to "Date" type
P=CDbl(X)
' Convert X to "Double" type
P=CInt(X)
' Convert X to "integer" type
P=CLng(X)
' Convert X to "Long" type
P=CSng(X)
' Convert X to "Single" type
P=CStr(X)
' Convert X to "String" type
P=Cvar(X)
' Convert X to "Variant" type
P=CVErr(X)
' Convert X to Error value
[Example]:
(1). CStr(13)+CStr(23)
' After converting the value into a string, connect it with the "+" sign, the result: 1323< /p>
(2). CInt("12")+12
' The string is converted into an integer and then added to 12. The result is: 24
(3 ). P=CInt(True)
' The output result is -1
' When converting Boolean values ??and numerical values, please note that Boolean values ??only have True and False, of which True is in memory is -1, False is stored as 0
(4). CBool(-0.001)
' The output result is True
' Convert the value to Boolean When typed, a value equal to 0 will be False, and a value not equal to 0 will be True.
2. Int(X), Fix(X): Take the integer value of X
[Format]:
P=Int(X) ' Take <= the maximum integer value of X
P=Fix(X) ' Take the integer part of X and directly remove the decimal< /p>
[Example]:
(1) Int(-54.6)
' The result is -55, take the largest integer <=-54.6
(2) Fix(54.6)
' The result is 54, take the integer and remove the decimal directly
(2) Commonly used mathematical functions
[Format ]:
1. Abs(N) takes the absolute value
Example: Abs(-3.5) Result: 3.5
2. Cos(N) cosine function
Example: Cos(0) Result: 1
3. Exp(N) Exponential function with base e
Example: Exp(3) Result: 20.068
4. Log(N) The natural logarithm with e as the base
Example: Log(10) Result: 2.3
5. Rnd[( N) Generate random numbers
Example: Rnd Result: number between 0--1
6. Sin(N) sine function
Example: Sin (0) Result: 0
7. Sgn(N) sign function
' Description: Take the positive and negative sign. Y=Sgn(X) If X>0, then Y=1; if X=0, then Y=0; if X<0, then Y= -1
8. Sqr(N) square root
< p>Example: Sqr(9) Result: 39. Tan(N) tangent function
Example: Tan(0) Result: 0
10 .Atn(N) inverse tangent function
Example: Atn(0) Result: 0
[Note]: In trigonometric functions, it is expressed in radians.
(1) String class functions:
1. ASC(X), Chr(X): Convert character character code
[Format]:< /p>
P=Asc(X) Returns the character code of the first character of string X
P=Chr(X) Returns the character whose character code is equal to X
[Example]:
(1)P=Chr(65)
'Output character A, because the ASCII code of A is equal to 65
(2) P=Asc("A")
'Output 65
2. Len(X): Calculate the length of string X
[Format]:< /p>
P=Len(X)
[Explanation]:
The length of the empty string is 0, and the space character is also counted as a character. Although a Chinese character takes up 2 Bytes, but also counts as a character.
[Example]:
(1) Let X="" (empty string)
The output result of Len(X) is 0
(2) Let X="abcd"
The output result of Len(X) is 4
(3) Let X="VB Tutorial"
Len(X) output result is 4
3. Mid(X) function: read the characters in the middle of string X
[Format]:
P=Mid(X,n)
Start from the nth character of X and read all subsequent characters.
P=Mid(X,n,m)
Start from the nth character of X and read the following m characters.
[Example]:
(1) X="abcdefg"
P=Mid(X,5)
The result is :P="efg"
(2) X="abcdefg"
P=Mid(X,2,4)
The result is P=" bcde"
4. Replace: Replace some specific strings in the string with other strings
[Format]:
P=Replace( X,S,R)
[Description]: Replace the string S in the string X with the string R, and then return.
[Example]:
X="VB is very good"
P=Replace(X,good,nice)
The output result is: P="VB is very nice"
5. StrReverse: Reverse string
[Format]:
P=StrReverse(X )
[Description]:
Return the string after the X parameter is reversed
[Example]:
(1)X ="abc"
P=StrReverse(X)
Output result: P="cba"
6. Ucase(X), Lcase(X) : Convert the uppercase and lowercase letters of English letters
[Format]:
P=Lcase(X)
'Convert the uppercase letters in the X string to lowercase
P=Ucase(X)
'Convert the lowercase letters in the X string to uppercase
[Description]: In addition to English letters, other characters or Chinese characters will not be affected.
[Example]:
(1) Let X="VB and VC"
The result of Lcase(X) is "vb and vc", The result of Ucase(X) is "VB AND VC"
7. InStr function: Find string
[Format]:
P=InStr(X ,Y)
Find the position where Y appears from the first character of X
P=InStr(n,X,Y)
Start from the Find the position where Y appears starting from n characters
[Explanation]:
(1) If Y is found in X, the return value is the first character of Y appearing in X location in.
(2) InStr(X,Y) is equivalent to InStr(1,X,Y).
(3) If the string length is long, or X is an empty string, or Y cannot be found in X, 0 will be returned.
(4) If Y is an empty string, 0 is returned.
(2) Date and time functions:
1. Year(X), Month(X), Day(X): Take out the year, month and day
< p>[Format]:P=Year(X)
Get the value of the "year" part of X
P=Month(X)
Get the value of the "month" part of X
P=Day(X)
Get the value of the "day" part of X
[Instructions] : Year returns the AD year. If there is only time and no date in Seconds
[Format]:
P=Hour(X)
Get the value of the "hour" part of X
P=Minute (X)
Get the value of the "minutes" part of X
P=Second(X)
Get the value of the "seconds" part of X
[Explanation]: The return value of Hour is between 0---23
[Example]:
X=10:34:23
P=Hour(X)
Q=Minute(X)
R=Second(X)
The output result is: P=10, Q= 34, R=23
3. DateSerial function: combine year, month and day into date
[Format]: DateSerial(Y,M,D)
Where Y is the year, M is the month, and D is the date
[Explanation]:
(1) If the M value is greater than 12, the month will be calculated backward from December M -12 months; if less than 1, the month is extrapolated 1-M months backward from January.
(2) If the date D is greater than the number of days in the current month, the date will be calculated backward from the number of days in the current month to D - the number of days in the current month; if it is less than 1, the date will be calculated forward from the 1st to 1-D day.
[Example]:
P=DateSerial(2000,02,02)
The result is P=2000/02/02
< p>4. TimeSerial function: combine hours, minutes and seconds to become time[Format]: P=TimeSerial(H,M,S)
where H is the number of hours and M is the number of minutes. S is the number of seconds
[Explanation]: The calculation principle is the same as DateSerial above
[Example]:
P=TimeSerial(6,32,45)< /p>
The result is: P=6:32:45
5. Date, Time, Now function: Read the system date and time
[Format]:
P=Date()
P=Time() p>
P=Now()
[Explanation]: These three functions have no parameters
[Example]:
If the current time is At 19:26:45 in the evening on August 29, 2003, then
P=Now()
The result is: P=2003-08-29 19:26:45< /p>
6. MonthName: Returns the month name
[Format]: P=MonthName(X)
[Description]: The X parameter can be passed in 1---12, then the return value is "one "Month", "February"..., but in the English Windows environment, "January", "February"...
[Example]:
P=MonthName (1)
Then P="January"
7. WeekdayName: Returns the name of the week
[Format]: P=WeekdayName(X)
[Description]: The X parameter can be passed in 1-7, then the return value is "Sunday", "Monday"..., but in the English windows environment, "Sunday", "Monday"...
[Example]:
P=WeekdayName(1)
The result is: P="Sunday"
Function name function function
Cbool(string) converted to Boolean value
Cbyte( string) is converted to a byte type value
Ccur(string) is converted to a currency value
Cdate(string) is converted to a day-ahead type value
Cdbl (string) Convert to a double value
Cint(string) Convert to an integer value
Clng(string) Convert to a long value
Csng( string) is converted to a single-precision value
Cstr(var) is converted to a string value
Str(var) a numerical value is converted to a string
Val(string ) Convert string to numeric value
****************************************** **
Abs(nmb) Returns the absolute value of a number
Atn(nmb) Returns the arctangent of a number
Cos(nmb) Returns the arctangent of an angle Cosistence value
Exp(nmb) returns the power of the natural exponent
Int(nmb) returns the integer (carry) part of the number 8.4-->9
Fix(nmb) returns the integer (truncated) part of the number 8.4-->8
Formatpercent(expression) returns the percentage
Hex(nmb) returns the data Hexadecimal number
Log(nmb) returns the natural logarithm
Oct(nmb) returns the octal number of the number
Rnd returns greater than "0" And random numbers less than "1"
Sgn(nmb) determines the sign of a number
Sin(nmb) returns the positive value of the angle
Sqr(nmb) Returns the square root of a number
Tan(nmb) Returns the tangent of a number
Asc(string) Returns an ASCII string
Chr(charcode) returns the character according to the character code
Instr(string,searchstr) returns the first character position of the searched string, string is the string, searchstr is the searched string
InstrRev(string,searchstr) Same as above, just start searching from the right
Lcase(var) Change the string to lowercase
Left(string,nmb) Return from string nmb strings starting from the left
Len(string) returns the length of the string
Ltrim(string) truncates the spaces on the left side of the string
Filter (inputstrings, value) returns the character set of the string array, Inputstrings is the string group, and value is the character found in the array
Rtrim(string) truncates the spaces on the right side of the string
< p>Trim(string) Trims the spaces before and after the stringMid(string,start,len) Returns len characters starting from the start position in the string
Replace(string, find,withstr) In the string string, replace the find string with withstr
Right(string,nmb) Return nmb strings starting from the right from the string
Space (nmb) Returns a string with specified spaces
StrComp(string1,string2) Compares two strings
Ucase(string) Changes the string to uppercase
******************************************
Date( ) Returns the current system date
DateAdd(interval,nmb,date) uses a base time to return the date with the specified added time interval. interval is the interval type, yyyy-year, m-month, d-day, h - hours, n - minutes.
DateDiff(interval,nmb1,nmb2) returns two time intervals, the meaning of interval is the same as above
Datevalue(date) plays the date part of Date
Day(date) Returns the number of days
FormatDatetime(date) Returns an expression formatted as a date
Hour(time) Returns the number of hours of time
Minute( time) returns the number of minutes in the time
Month(date) returns the month in the date
Now() returns the system date and time
Second(time) Returns the number of seconds in the time
Time() returns the current time of the system
Weekday(date) returns the day of the week
WeekdayName(date) returns the day of the week Chinese name
Year(date) returns the year
IsArray(var) determines whether a variable is an array
IsDate(var) determines whether a variable is a date< /p>
IsNull(var) determines whether a variable is empty
IsNumeric determines whether an expression contains a numerical value
IsObject(var) determines whether a variable is an object
TypeName(var) returns the data type of the variable
****************************** ******
Array(list) returns an array
CreateObject(class) creates an object
GetObject(pathfilename) gets the file object
Inputbox(prompt) provides a dialog box for inputting data
LBound(arrayP) returns the minimum index of the array
Msgbox(string) outputs a message box
p>Split(liststr) returns a one-dimensional array from a list string
Ubound(array) returns the maximum index of the array