VB函数大全2
- 格式:pdf
- 大小:146.02 KB
- 文档页数:9
VB基本函数大全Abs 函数:返回数的绝对值。
And 运算符:执行两个表达式的逻辑连接。
Array 函数:返回含一数组的变体。
Asc 函数:返回字符串首字母的 ANSI 字符代码。
赋值运算符 (=):给变量或属性赋值。
Atn 函数:返回数的反正切值。
调用语句将控制移交 Sub 或 Function 过程。
CBool 函数:返回已被转换为 Boolean 子类型的变体的表达式。
CByte 函数:返回已被转换为字节子类型的变体的表达式。
CCur 函数:返回已被转换为货币子类型的变体的表达式。
CDate 函数:返回已被转换为日期子类型的变体的表达式。
CDbl 函数:返回已被转换为双精度子类型的变体的表达式。
Chr 函数:返回指定 ANSI 字符码的字符。
CInt 函数:返回已被转换为整数子类型的变体的表达式。
Class 对象:提供对已创建的类的事件的访问。
Class 语句声明类名Clear 方法:清除 Err 对象的所有属性设置。
CLng 函数:返回已被转换为 Long 子类型的变体的表达式。
颜色常数颜色常数列表。
比较常数用于比较运算的常数列表。
连接运算符 (&) :强制两个表达式的字符串连接。
Const 语句:声明用于字母值的常数。
Cos 函数:返回角度的余弦值。
CreateObject 函数:创建并返回对“自动”对象的引用。
CSng 函数:返回已被转换为单精度子类型的变体的表达式。
CStr 函数:返回已被转换为字符串子类型的变体的表达式。
日期和时间常数:在日期和时间运算中用来定义星期几和其他常数的常数列表。
日期格式常数用于日期和时间格式的常数列表。
Date 函数:返回当前系统日期。
DateAdd 函数:返回加上了指定的时间间隔的日期。
DateDiff 函数:返回两个日期之间的间隔。
DatePart 函数:返回给定日期的指定部分。
DateSerial 函数:返回指定年月日的日期子类型的变体。
v b常用函数一览表(总3页) -CAL-FENGHAI.-(YICAI)-Company One1-CAL-本页仅作为文档封面,使用请直接删除常用内部函数数学函数函数功能示例结果说明Abs(x)绝对值Abs(-50.3)50.3Exp(x) 自然指数Exp(2) e*e e(自然对数的底)的某次方Fix(x) 取整(取参数的整数部分)Fix(-99.8) -99Int(x)取整(取小于或等于参数的最大整数)Int(-99.8)Int(99.8)-10099Log(x) 常用对数Log(1) 0 求自然对数值Rnd 随机产生0~1的单精度值Int(6*Rnd)+11~6要产生一个从Min到Max的整数,应使用公式Int((Max-Min+1)*Rnd+Min)Round(x,n)按小数位数四舍五入Round(3.14159,3) 3.142第2个参数为小数位数Sgn(x) 取参数的符号值Sgn(8.8)Sgn(-8.8)Sgn(0) 1-10 参数大于0,返回1参数小于0,返回-1参数等于0,返回0Sin(x) 正弦 1三角函数以“弧度”为单位Cos(x) 余弦/180*180) -1Atn(x) 计算反正切Atn(1) 0.7854Tan(x) 计算正切 1Sqr(x) 算术平方根Sqr(9) 3 相当于字符串函数函数功能示例结果说明Len(x)求字符串的长度(字符个数)Len("Vb技术")4LenB(x) 求字符串的字节个数LenB("Vb技术") 8 VB中采用Unicode(ISO 字符标准)来存储字符,所有字符都占2个字节Mid(x,n1,n2)从x字符串左边第n1个位置开始向右取n2个字符Mid("Vb技术",2,2)"b技"。
一、算术函数1、Abs(<表达式>)返回数值表达式的绝对值。
如:Abs(-3)=32、Int(<数值表达式>)向下取整。
如:Int(3.25)=3,Int(-3.25)=-43、Fix(<数值表达式>)取整函数。
如:Fix(3.25)=3,Fix(-3.25)=-34、Round(<数值表达式>[,<表达式>])按指定位数四舍五入。
如:Round(3.2553,1)=3.3,Round(3.754,0)=45、sqr(<数值表达式>)计算平方根。
如:sqr(9)=36、Rnd(<数值表达式>)Int(Rnd*(b-a)+a ): 在[a,b )区间内产生随机整数Randomize[(x)]:每次运行时,要产生不同序列的随机数如:产生1-100的随机数: Int(Rnd *100)+1产生一个二位数: Int(Rnd*90)+10产生1-30的随机数: Int(Rnd*30)+1二、字符串函数1、InStr([Start,]<str1>,<str2>[,Compare])求str2在字符串str1中最早出现的位置(Start设置开始查找位置,缺省为1;Compare指定比较方法:0为二进制比较,1为不区分大小写,2用于数据库信息比较)。
如:str1=”98765”Str2=”65”S=InStr(str1,str2) …返回4S=InStr(3,"aSsiAB","a",1) …返回5 从字符s开始找,不区分大小写2、Len(<字符串表达式>或<变量名>)返回字符串所含字符数。
如:Dim str As String*10Dim iStr=”123”i=12len1=Len(“12345”)…返回5len2=Len(12) …出错len3=Len(i) …返回2len4=Len(“考试中心”)…返回4len5=Len(str) …返回103、字符串截取函数Left(<字符串表达式>,<N>) ‘从字符串左边起截取N个字符Right(<字符串表达式>,<N>) ‘从字符串右边起截取N个字符Mid(<字符串表达式>,<N1>,<N2>) ‘从字符串第N1个起截取N2个字符(如果N2省略,则从N1个起截到底)如:str1=”opqrst”Str2=”计算机等级考试”Str=Left(str1,3) …返回“opq”Str=Left(str2,4) …返回“计算机等”Str=Right(str1,2) …返回“st”Str=Left(str2,2) …返回“考试”Str=Mid(str1,4,2) …返回“rs”Str=Mid(str2,4) …返回“计算机等级考试”4、Space(<数值表达式>)返回数值表达式值指定的空格字符数。
一、类型转换函数1、Int(x):求不大于自变量x的最大整数2、Fix(x):走失一个浮点数的小数部分,保存其整数部分3、Hex$(x):把一个十进制数转换为十六进制数4、Oct$(x):把一个十进制数转换为八进制数5、Asc(x$):返回字符串x$中第一个字符的ASCII字符6、CHR$(x):把x的值转换为相应的ASCII字符7、Str$(x):把x的值转换为一个字符串8、Cint(x):把x的小数部分四舍五进,转换为整数9、Ccur(x):把x的值转换为货币类型值,小数部分最多保存4 位且主动四舍五进10、CDbl(x):把x值转换为双精度数(Double)11、CLng(x):把x的小数部分四舍五进转换为长整数型数(Long)12、CSng(x):把x值转换为单精度数(single)13、Cvar(x):把x值转换为变体类型值(variant)14、VarPtr(var):获得变量var的指针二、数学函数1、Sin(x):返回自变量x的正弦值2、Cos(x): 返回自变量x的余弦值3、Tan(x): 返回自变量x的正切值4、Atn(x): 返回自变量x的横竖切值5、Abs(x): 返回自变量x的尽对值6、Sgn(x): 返回自变量x的标记,即卖x为负数时,返回-1;卖x为0时,返回0;卖x为正数时,返回17、Sqr(x):返回自变量x的平方根,x务必大于或即是08、Exp(x):返回以e为底,以x为指数的值,即求e的x次方三、日期函数1、Day(Now):返回卖前的日期2、WeekDay(Now):返回卖前的星期3、Month(Now):返回卖前的月份4、Year(Now):返回卖前的年份5、Hour(Now):返回小时(0~23)6、Minute(Now):返回分(0~59)7、Second(Now):返回秒(0~59)四、随机数函数1、Rnd[(x)]:孕育发生一个0~1之间的单精度随机数2、Randmize[(x)]:功能同上,不过更好五、字符串函数1、LTrim$(字符串):走失字符串左边的空缺字符2、Rtrim$(字符串):走失字符串右边的空缺字符3、Left$(字符串,n):取字符串左部的n个字符4、Right$(字符串,n):取字符串右部的n个字符5、Mid$(字符串,p,n):从地位p开端取字符串的n个字符6、Len(字符串):测试字符串的长度7、String$(n,字符串):返回由n个字符组成的字符串8、Space$(n):返回n个空格9、InStr(字符串1,字符串2):正在字符串1中查找字符串210、Ucase$(字符串):把小写字母转换为大写字母11、Lcase$(字符串):把大写字母转换为小写字母六、窗体输进输出函数1、Print(字符串):正在窗体输出字符串,可以用”&”对变量进行连接后输出2、Tab(n):把光标移到该行的n开真个地位3、Spc(n):跳过n个空格4、Cls:清除卖前窗体内的显现内容5、Move 左上角x,左上角y,宽度,高度:挪动窗体或控件6、InputBox(prompt,…):跳出一个数据输进窗口,返回值为该窗口的输进值7、MsgBox(msg,[type]…):跳出一个提示窗口七、文件作函数1、Open 文件名[For方式] [Access存取类型] [锁定] AS [#]文件号[Len=记录长度]功能:为文件的输进输出分派缓冲区,并确定缓冲区所使用的存取方式阐明释义:1) 方式:指定文件的输进输出方式,可选,默许是Random,可以是以下值a、Output:指定顺序输出方式,将覆盖原有内容b、Input:指定顺序输进方式c、Append:指定顺序输出方式,正在文件未尾追加内容d、Random:指定随机存取方式,也是默许方式,正在Random 方式时,假如没有Access子句,则正在施行Open语句时,VB将按下列顺序打开文件:读/写、只读、只写e、指定二进制文件。
vb函数大全(VBfunctionDaquan)vb函数大全(VB function Daquan)vb函数大全(VB function Daquan)VB commonly used function Daquan 2008-03-08 19:39, now programming software, such as VB, C++, etc., mostly with a powerful library of functions, you can save effort to complete a variety of functions. Most of the time, you can't remember the function or function format that implements a function, which results in a lot of trouble in programming. As a programmer, I have a deep understanding of this. Therefore, specially prepared several VB common function introduction, for your study or reference. There are inappropriate places to say, but also welcome in the Forum on this web site, we study.(I) type conversion class functions1. CType (X)[format]:P=CBool ("X") converts X to "Boolean" (Boolean) typeP=CByte ("X") converts X to "Byte" typeP=CCur (X) 'converts X to the' Currency 'typeP=CDate ("X") converts X to "Date" typeP=CDbl ("X") converts X to "double precision" (Double) type P=CInt (X) converts the X to an integer (Integer) typeP=CLng ("X") converts X to "long integer" (Long) typeP=CSng (X) converts X to a single precision (Single) typeP=CStr (X) converts the X to a string (String) typeP=Cvar (X) converts the X to a variant (Variant) typeP=CVErr (X) 'converts X to a Error value[paradigm]:(1) CStr (13) +CStr (23) after the value is converted into astring, and is connected with "+" number, and the result is: 1323(2) CInt ("12") +12'strings are converted into integers and then summed up with 12. Results: 24(3) P=CInt (True) ', the output is -1"Boolean and numeric conversions should be noted, Boolean values are only True and False, in which True is -1 in memory, and False is 0(4) CBool (-0.001) ', the output is TrueWhen the value is converted to Boolean, the value equal to 0 will be False, and the value not equal to 0 will be True.2. Int (X), Fix (X): take the integer value of X[format]:P=Int (X) 'takes the maximum integer value of <=XP=Fix ("X") takes the integer part of X and removes the decimal directly[paradigm]:(1) Int (-54.6) ', the result is -55, take the maximum integer of<=-54.6(2) Fix (54.6) ', the result is 54, take an integer and remove the decimal directly(two) commonly used mathematical functions[format]:1. Abs (N) takes absolute valueExample: Abs (-3.5) results: 3.52. Cos (N) cosine functionExample: Cos (0): 13. Exp (N) e is the exponential function at the bottom Example: Exp (3): 20.0684. Log (N) the natural logarithm based on eExample: Log (10): 2.35. Rnd[(N)] generates random numbersExample: Rnd result: the number between 0--16. Sin (N) sine functionExample: Sin (0): 07. Sgn (N) signed functionExplanation: take the plus sign. Y=Sgn (X) is both X>0 and Y=1; X=0 is Y=0; X<0 is Y=; -18. Sqr (N) square rootExample: Sqr (9): 39. Tan (N) tangent functionExample: Tan (0): 010.Atn (N) reverse functionExample: Atn (0): 0[note] in trigonometric functions, expressed in radians. (string) class function of string:1., ASC (X), Chr (X): conversion character, character code[format]:P=Asc (X) returns the character code of the first character of string XP=Chr (X) returns characters equal to X characters[paradigm]:(1) P=Chr (65);'output character' A 'because the ASCII of A is equal to 65(2) P=Asc ("A")Output 652. Len (X): calculate the length of the string X[format]:P=Len (X)[instructions]:The empty string length is 0, and the space character is alsoa character. A Chinese text occupies 2 Bytes, but is also counted as a character.[paradigm]:(1) make X= "" (empty string)The output of Len (X) is 0(2) make X= "ABCD""The output of Len (X) is 4(3) make X= VB tutorial"The output of Len (X) is 43. Mid (X) function: read the string X characters in the middle [format]:P=Mid (X, n)Read by the N character of X, read all the characters behind.P=Mid (X, N, m)Read by the N character of X, read the M characters behind. [paradigm]:(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: replaces some of the string in a string with another string[format]:P=Replace (X, S, R)[explanation]: replace the string S in string X with string R, and then return.[paradigm]:X=, VB, is, very, good"P=Replace (X, good, nice)The output is: P=, VB, is, very, nice"5. StrReverse: inverted string[format]:P=StrReverse (X)[instructions]:Returns the string after the X parameter is reversed[paradigm]:(1) X= "ABC""P=StrReverse (X)Output: P= "CBA""6., Ucase (X), Lcase (X): convert English letters to uppercase and lowercase[format]:P=Lcase (X)Convert uppercase characters from X strings to lowercaseP=Ucase (X)"Convert lowercase letters from X strings to uppercase."[instructions] no other characters or Chinese characters will be affected except English letters.[paradigm]:(1) make X=, VB, and, VC"The result of Lcase (X) is "VB, and, VC", and Ucase (X) is "VB AND VC""7. InStr function: finding strings[format]:P=InStr (X, Y)Locate the position of the Y from the first character of the X P=InStr (n, X, Y)Find the position of the Y from the X n character[instructions]:(1) if the Y is found in X, the return value is the place where the first character of the Y appears in X.(2) InStr (X, Y) is equivalent to InStr (1, X, Y).(3) if the string length, or X is an empty string, or Y is not found in X, 0 is returned.(4) if Y is an empty string, returns 0.Date time class function:1., Year (X), Month (X), Day (X): take out year, month, day[format]:P=Year (X)Take out the value of the X "year" sectionP=Month (X)Take out the value of the X "month" sectionP=Day (X)Take out the value of the X "day" section[description]:Year returns in AD, and if X has only time and no date, the date is #1899/12/30#2., Hour, Minute, Second function: take out, divide, or second[format]:P=Hour (X)Take the value of the "X" part of the "when"P=Minute (X)Take out the value of the "X" partP=Second (X)Take out the value of the X "seconds" section[indicates that the return value of]:Hour is between 0---23 [paradigm]:X=10:34:23P=Hour (X)Q=Minute (X)R=Second (X)Output results: P=10, Q=34, R=233., DateSerial function: merge year, month, date, become date[format]:DateSerial (Y, M, D)Where Y is the year, M is the month, and D is the date[instructions]:(1) if the value of M is greater than 12, the month will beextrapolated from December to M-12 months; if less than 1, the month will be extrapolated from January to 1-M months.(2) if the date D is greater than the number of days in that month, the date from the date of the month, the number of D- months later; if less than 1, then the date from 1 days forward projections 1-D days.[paradigm]:P=DateSerial (2000,02,02)The result is P=2000/02/024.TimeSerial function: when merging, minutes and seconds become time[format]:P=TimeSerial (H, M, S)H is the number of hours, M is minutes, and S is seconds[explanation]: the principle of calculation is the same as that of DateSerial above[paradigm]:P=TimeSerial (6,32,45)The result was: P=6:32:455.Date, Time, Now function: read the date and time of the system[format]:P=Date ()P=Time ()P=Now ()[explanation]: none of these three functions have arguments [paradigm]:If the current time is 19:26 on August 29, 2003 evening, 45 seconds, thenP=Now ()The result is: P=2003-08-29 19:26:456.MonthName: returns the name of the month[format]:P=MonthName (X)[to indicate that the]:X parameter can be passed in to 1---12, returns the value of "month" and "February""...... But in English Windows, the return is "January", "February""......[paradigm]:P=MonthName (1)"P=" one month"7.WeekdayName: returns the name of the week[format]:P=WeekdayName (X)[shows that the]:X parameter can be passed in 1 - 7, and returns the value "Sunday", Monday"...... But in English windows, the return is "Sunday", "Monday""......[paradigm]:P=WeekdayName (1)The result is: P=, Sunday"Mathematical function of /doc/c57f7c690229bd64783e0912a21614 7916117e29.html function DaquanAbs (Num) takes absolute value.Exp (Num) returns the value of e at the bottom and num asan exponent, such as Exp (2) returning the e^2 value.Log (Num) returns the natural pair value of parameter num, which is the Double type, that is, the logarithm based on E.Hex (Num) converts the parameter num to 16.Oct (Num) converts the parameter num to 8Sign (Num) returns the positive and negative sign of the parameter. If num is greater than 0, the return value is 1; if num equals 0, thenthe return value is 0; if num is less than 0, then the return value is -1.Sqrt (Num) returns the square root of the argument, Double type.Atan (Num) tangent functionSin (Num) sine functionCos (Num) cosine functionTan (Num) tangent functionRand (Num, [int]) will enter the parameter num four, five, to specify four to five into which decimal, you can add second parameters int. For example, Round (12.456) returns the value of 12 Round (12.4567,3) returns 12.457.Rnd [[nun]] produces a random number less than 1, greater than or equal to 0, of type Single. If num is less than 0, then each will return the same number; if you don't provide the parameters or parameter is greater than 0, so in order to generate a random number next, this is the default value; if the parameter num is equal to 0, then returns the last generated random number. In order to generate different random numbers each time, it is better to use the Randomize statement before using the Rand () function. To randomly generate an integer from N to M, you can use the following formula: Int (Rand ()) *M-N+1, +N.Pow (x, y) seeks the Y power of X.Val (STR) converts the number in a string to Integer or Double type.Str (Num) converts a numeric type parameter into a string to return.When the Fix (Num) parameter is greater than 0, the decimal part is removed; when the parameter is less than 0, the value returned is greater than or equal to the parameter value.When the Int (Num) parameter is greater than 0, the decimal part is removed; when the number is less than 0, the parameter is returned less than or equal to the parameter value.。
VB.函數大全二、字符串函数<一>字符串转换函数(1)Lcase(str):将字符串str转换成小写字母。
(2)Ucase(str):将字符串str转换成大写字母。
(3)Asc(St):取得字符串str的第一个字符ASCII码。
(4)Chr(int):以ASCII码来取得字符内容。
如:chr(65)会返回字符A。
(5)StrReverse(str):取得字符串str内容反转后的结果。
如:StrReverse("Love")返回值为"evoL"。
<二>依照指定格式转换字符串函数StrConv()语法格式:StrConv(str As String,ConverSion As VbStrConv[,LocaleID As Integer])As String说明:根据参数ConverSion指定的格式将参数str转换完毕的结果返回。
参数ConverSion属于Microsoft.VisualBasic.VbStrConv枚举,其成员如下:VbstrConv枚举成员说明VbStrConv.None不执行转换。
VbStrConv.Nove.LinguisticCasing使用大小写的语言风格,而不是文件系统(默认值)。
VbStrConv.UpperCase将字符串转换成大写字母。
VbStrConv.LowerCase将字符串转换成小字字母。
VbStrConv.ProPerCase将字符串中每个单字的第一个字母转换成大写。
VbStrConv.Widw*将字符串中的半角字符转换成全角字符。
VbStrConv.Narrow*将字符串中的全角字符转换成半角字符。
VbStrConv.KataKana**将字符串中平假名字符转换成片假名字符。
VbStrConv.HiraGanna**将字符串中的片假名字符转换成平假名字符。
VbStrConv.SimpLifedChinese*将繁体汉字转换成简体中文。
VB.函數大全二、字符串函数<一>字符串转换函数(1)Lcase(str):将字符串str转换成小写字母。
(2)Ucase(str):将字符串str转换成大写字母。
(3)Asc(St):取得字符串str的第一个字符ASCII码。
(4)Chr(int):以ASCII码来取得字符内容。
如:chr(65)会返回字符A。
(5)StrReverse(str):取得字符串str内容反转后的结果。
如:StrReverse("Love")返回值为"evoL"。
<二>依照指定格式转换字符串函数StrConv()语法格式:StrConv(str As String,ConverSion As VbStrConv[,LocaleID As Integer])As String说明:根据参数ConverSion指定的格式将参数str转换完毕的结果返回。
参数ConverSion属于Microsoft.VisualBasic.VbStrConv枚举,其成员如下:VbstrConv枚举成员说明VbStrConv.None不执行转换。
VbStrConv.Nove.LinguisticCasing使用大小写的语言风格,而不是文件系统(默认值)。
VbStrConv.UpperCase将字符串转换成大写字母。
VbStrConv.LowerCase将字符串转换成小字字母。
VbStrConv.ProPerCase将字符串中每个单字的第一个字母转换成大写。
VbStrConv.Widw*将字符串中的半角字符转换成全角字符。
VbStrConv.Narrow*将字符串中的全角字符转换成半角字符。
VbStrConv.KataKana**将字符串中平假名字符转换成片假名字符。
VbStrConv.HiraGanna**将字符串中的片假名字符转换成平假名字符。
VbStrConv.SimpLifedChinese*将繁体汉字转换成简体中文。
VbStrConv.TraditionalChinese将简体中文转换成繁体汉字。
注:*适用于亚州地区设置;**仅适用于日本。
例如:StrConv("I AM HAPPY",VbStrConv.LowerCase)返回值为:i am happy。
<三>字符串搜索、比较、筛选与替换函数(1)字符串比较比较函数StrComp()语法:StrComp(str1As String,str2As String[,ampare As pareMethod]) As Integer说明:返回表示str1和str2两个字符串参数比较结果,若str1小于str2,则返回-1;若str1等于str2,返回0;若str1大于str2,若返回1。
选择性参数Compare的值有Binary(区分大小写)和Text(不区分大小写)两种,前者为默认值。
(2)筛选字符串数组函数Filter()语法:Filter(Source()As{Object|String},match As String[,include As Boolean[,compare As pareMethod]]As String()说明:从一维字符串数组Source()中筛选包含match字符串的子数组。
若选择性参数include 为True(默认),表示从字符串数组Source()中筛选包含match字符串的子数组;若选择性参数include为false,表示字符串数组source()中筛选不包含match字符串的子数组;选择性参数compare的值有Binary(区分大小定)和Text(不区分大小字)两种,前者为默认值,决定了字符串的比较方式。
例如:Source()={"abc","abdfe","ghdf","pqs"},那么filter (Source,"ab",True,CompareMethod.Binary)会返回{"abc","abdfe"}。
(3)替换字符串函数RePlace()语法:RePlace(str As String,find As String,replacement As String[,start As Integer[,count As Integer[,compare As pareMethod]]]As String说明:将str字符串内的find子字符串替换为replacement子字符串。
选择性参数start表示从str字符串的第start个字符开始查找find子字符串,默认为1;选择性count表示做几次替换,默认为-1,表示执行所有可能的替换;选择性参数compare的值有Binary(区分大小定)和Text(不区分大小字)两种,前者为默认值,决定了字符串的比较方式。
如:str="shopping list"那么Relace(str,"o","i")会返回"Shipping list"。
(4)查找字符串函数InStr()语法:InStr(start As Integer,str1As String,str2As String[,compare As pareMethod])As String说明:返回str2字符串在str1字符串中第一次出现的位置。
若str1为空字符串("")或str2没有出现在str1或start大于str2的长度,就返回0;若str2为空字符串(""),就返回start;选择性参数compare的值有Binary(区分大小定)和Text(不区分大小字)两种,前者为默认值,决定了字符串的比较方式。
如:Instr(3,"Hell Wold",0")返回5。
(5)查找字符串函数Instrrev()语法:InStrRev(str1As String,Str2As Interger[,start As Integer[,compare As pareMethod]])As Integer说明:InStrRev()函数的用途和InsStr()函数相似,但改从字符串的右边开始检查str2字符串在str1字符中第一次出现的位置不同。
如:InStrRev("Hello Word","0")返回3。
(6)将字符串数组组成单一字符串函数join()语法:Jon(Source()As{Object|String}[,delimiter As String])As String说明:将字符串数组Source()内的每个字符串组成单一字符串返回,选择性参数delimter表示每个字符之间的分隔符,默认为空字符串("")。
如:Source ()={"Janifer","Peter","Jean","Robort"},那么join(Source)会返回"Janifer Perter Rober"。
(7)将字符串分解成子字符数组函数Split()语法:Split(str As String[,delimiter As String[,limit As Integer[,compare As pareMethod]]])As String说明:将组成字符串str的每一个字符串放进字符串数组内返回。
选择性参数delimiter表示每个子字符串之间的分隔符,默认值为空字符串("");参数limit是要返回的子字符串数目,默认为-1,表示返回所有子字符串;参数compare的值有Binary(区分大小定)和Text(不区分大小字)两种,前者为默认值,决定了字符串的比较方式。
如:str="I am Happy.",那么Split(str)会返回字符串数组{"I","am","Happy"}。
<四>字符串操作数(1)Len(str):获取字符串长度;也可以测试变量名所存储数据空间的大小。
Len(字符串)或Len(变量名)(2)Space(int):由空格符组成的字符串,返回int个空格。
(3)StrDup(int,char):由指定字符组成的字符串,返回由chr字符所组成部分的字符串,int的类型的onteger,chr为Char或String类型,若为String,则返回由int个该字符串中第一个字符所组成的字符串。
如:StrDup(3,"I am Happy.")返回"III"。
(4)Left(str,int):从字符串str左边返回int个字符。
(5)Right(str,int):从字符串str右边返回int个字符。
(6)Mid(str,int1,int2):从字符串str的第int1个字符开始返回int2个字符,int2可省略,若int2省略则从int1个字符开始截取到最后。
如:Mind("Happy Birthday",3,5)返回"ppy B"。
(7)LTirm(str):删除左边空格。
(8)RTim(str):删除右边的空格。
(9)Trim(str):删除两边的空格。
三、日期时间函数<一>获取/设置目前日期时间函数(1)Now():返回系统目前的日期和时间。
如:2007-3-29早上10:38:22(2)Today():返回或设置系统目前的日期。
(3)TimeOfDay():返回或设置系统目前的时间。
(4)DataString():以"yyy-mm-dd"格式返回或设置系统目前时间。
(5)Timer():以Double类型返回自午夜到今所经过的秒数和毫秒数,秒数是返回值的整数部分,毫秒数则是小数部分。
<二>返回日期时间函数(1)合并年月日成日期函数DateSerial()格式:DateSerial(year As Integer,month As Integer,day As Integer)As DateTime说明:将参数所指定的年月日合并成日期返回,参数year的值须是介于1~9999的整数,若是介于0~99的整数,将被解释为1930~2029,若是小于1的整数,将自目前年底中减去;参数day的值须是介于1~31的整数,若是小于1的整数,将自目前日期中减去。