vb常用函数一览表
VB常用函数表

ASP纯ASPVBscript常用函数:1.数值型函数:abs(num): 返回绝对值sgn(num): num>0 1; num=0 0; num<0 -1;判断数值正负hex(num): 返回十六进制值直接表示:&Hxx 最大8位oct(num): 返回八进制值直接表示:&Oxx 最大8位sqr(num): 返回平方根num>0int(num): 取整int(99.8)=99; int(-99.2)=100fix(num): 取整fix(99.8)=99; fix(-99.2)=99round(num,n): 四舍五入取小数位round(3.14159,3)=3.142 中点数值四舍五入为近偶取整round(3.25,1)=3.2log(num): 取以e为底的对数num>0exp(n): 取e的n次幂通常用num^nsin(num): 三角函数,以弧度为值计算(角度*Pai)/180=弧度con(num); tan(num); atn(num) 2.字符串函数:len(str):计算字符串长度中文字符长度也计为一!mid(str,起始字符,[读取长度]):截取字符串中间子字符串left(str,nlen):从左边起截取nlen长度子字符串right(str,nlen):从右边起截取nlen长度子字符串Lcase(str):字符串转成小写Ucase(str):字符串转成大写trim(str):去除字符串两端空格Ltrim(str):去除字符串左侧空格Rtrim(str):去除字符串右侧空格replace(str,查找字符串,替代字符串,[起始字符,替代次数,比较方法]):替换字符串注:默认值:起始字符1;替代次数不限;比较方法区分大小写(0)InStr([起始字符,]str,查找字符串[,比较方法]):检测是否包含子字符串可选参数需同时选返回起始位置InStrRev(str,查找字符串[,起始字符][,比较方法]):反向检测是否包含子字符串返回起始位置space(n):构造n个空格的字符串string(n,str):构造由n个str第一个字符组成的字符串StrReverse(str):反转字符串split(str,分割字符串[,次数][,比较方法]):以分割字符串为分割标志将字符串转为字符数组可选参数需同时选3.数据类型转换函数:Cint(str):转换正数True -1;False 0;日期距离1899/12/31天数;时间上午段0;下午段1;Cstr(str):日期输出格式yyyy/mm/dd;时间输出格式Am/Pm hh:mm:ssClng(str):与Cin()类似Cbool(num):num不为零True;反之FalseCdate(str):转换日期格式0:#Am 12:00:00#;正数距离1899/12/31天数的日期;浮点数日期+小数时间Cbyte(num):num<255 转换为字节Csng(str):转换为单精度数值Cdbl(str):转换为双精度数值Ccur(str):转换为现金格式4.时间函数:date:取系统当前日期time:取系统当前时间now:取系统当前时间及日期值Datetime类型timer:取当前时间距离零点秒值,计时器,可计算时间差DateAdd(间隔单位,间隔值,日期):推算相邻日期DateDiff(间隔单位,日期一,日期二):计算时间差日期二-日期一Datepart(间隔单位,日期):计算日期的间隔单位值Dateserial(date):输出日期值(按序列计算)Timeserial(time):输出时间值(按序列计算)DateValue(datetime):取出字符串中日期值Timevalue(datetime):取出字符串中时间值weekday(date):计算星期几MonthName(date):输出月分名year(datetime):截取年份month(datetime):截取月份day(datetime):截取日hour(datetime):截取小时minute(datetime):截取分钟second(datetime):截取秒5.其它函数:Array(unit,..):动态生成数组Asc(str):输出字符串第一个字符的ASCII码Chr(asc):转换ASCII为字符Enter:Chr(13)&Chr(10)Filter(数组名称,关键字符串,[,包含][,比较方法]):将字符串数组中含有关键字符串的元素存成新的数组(默认)[包含]为false则取不包含的元素Join(ArrayName):将数组中元素连成字符串Ubound(ArrayName[,维数]):取得数组相应维数的上界Lbound(ArrayName[,维数]):取得数组相应维数的下界一般为0Randmize n:启动随机数种子Rnd(n):取得随机数,n>0或为空,取序列下一随机值,n<0,随机值相同,n=0,生产与上一随机值相同的数取介于A和B之间的随机正数C,公式:C=Int((B-A+1)*Rnd+A) 条件(B>A)子程序和自定义函数Sub StrSubName Function StrFunName(arg[1],..)子程序体函数体Exit Sub 中途跳出Exit Function 中途跳出End Sub StrFunName=Value 返回值End Function[call] StrSubName 引用子程序Var=StrFunName(arg[1],..) 引用函数子程序和自定义函数可以递归调用;ASP六大对象常用语句示范:Response:Response.write StrVar/"String":向网页写出参数值或字符串等同于在Html标记中嵌入<%=StrVar/"String"%>Response.End:停止页面编译,并将已经编译内容输出到浏览器Response.Buffer=True|False:页面编译时是否使用缓存的设置,一般在页面头部设置Response.Flush:强制输出页面已编译部分内容Response.Clear:将缓冲区内的数据清除Response.Redirect URL:停止页面编译或输出,转载指定所需页面Response.IsClientConnected:返回True|False,检测用户是否还处于连接状态Response.Charset(CharsetName):设置页面编码类型,即<meta http-equiv="Content-Type" content="text/html; charset=gb2312">Response.ContentType [= ContentType ]:设置页面文件类型,同上Response.Expires [= number]:设置页面失效时间,单位分钟Response.ExpiresAbsolute [= [date] [time]]:设置页面失效的绝对时间Response.Status = StatusDescription:设置页面状态描述Request:Request("PassStrName"):读取网页传递值,包括表单及以?PassStrName=value&PassStrName_n=value_n形式Request[.collection|property|method](variable)Request.querystring("PassStrName"):读取Get方法传递的表单值和?PassStrName=value Request.QueryString(Varible)[(Index).Count]Request.form("PassStrName"):读取Post方法传递的纯表单域的值Request.Form(Parameter)[(Index).Count]Request.ServerVaribles(Server Environment Variable):读取客户端系统环境变量,详见参考Request.BinaryRead(Count):读取指定字节数的传送值Request.TotalBytes:查询体的长度,以字节为单位,只读注:同名表单如:CheckBox如有多项值,传递形式如右,StrName=value1,value2,...需要用Split函数分割各项值Multiple的Select表单与CheckBox类似,TextArea的值可包含换行字符,用Replace转为<br>,以满足格式需要Session:(用户全局变量)Session("SesName")=value:存储Session变量值,也可读取该值Session("SesName")=Empty:判断Session值是否存在的两种方法IsEmpty(Session("SesName"))=True|False:判断Session值是否存在的两种方法Session.TimeOut=num:设置Session变量的存在时效,单位分钟Session.Abandon:清除所有Session变量值Session.SessionID:Session变量的ID序列号,只读Application:(应用程序全局变量)Application("AppName")=value:存储Application变量值,也可读取该值Application("AppName")=Empty:判断Application值是否存在的两种方法IsEmpty(Application("AppName"))=True|False:判断Application值是否存在的两种方法Application.Lock:Application变量值锁定,防止同时更改变量值Application.UnLock:Application变量值解锁,允许更改变量值注:Session与Application变量都可以用来存储数组和系统对象,引用方法是变量名相当于数组名而已,但不能直接改变其值,需要借助临时数组修改值后,再赋给Session与Application变量Global.asa文件的结构:<% @language="VBscript"%><% Sub Application_OnStart ...End SubSub Application_OnEnd ... End SubSub Session_OnStart ...End SubSub Session_OnEnd ... End Sub%>Server:Server.MapPath("FileUrl"):映射文件名的服务器站点绝对地址,Path=Server.MapPath(./)可以得到虚拟目录根路径Server.HtmlEncode("string"):转换为可以直接显示带Html格式的字符串,如:<,>等Server.URLEncode( "string"):转换为浏览器地址编码set Var=Server.CreatObject("ObjName"):创建对象变量Server.ScriptTimeout = NumSeconds:ASP程序页面执行时限,以秒为单位Cookies: 存储在用户本机的临时变量,每个Cookie的最大字节4KB,最多可以有300个Cookie 1.2MBResponse.cookies("StrCookieName")=value:存储Cookie变量值,也可读取该值Response.cookies("StrCookieName")="":判断是否为空Response.cookies("StrCookieName").Expires=Date:变量有效期,以天为单位,小于当前时间立即失效Response.Cookies(Cookie[(key).Attribute]):标准语法ObjectContext 控制ASP的事务处理ObjectContext.OnTransactionAbort:由放弃的事务处理事件激发,在脚本完成处理后发生ObjectContext.OnTransactionCommit:由成功的事务处理事件激发,在脚本完成处理后发生ObjectContext.SetAbort:显式的放弃一次事务处理ObjectContext.SetComplete:覆盖前面任何调用ObjectContext.SetAbort方法的调用Msgbox "string"/StrName:VBscript提示框表单的Onsubmit事件:在同一页面写入FunctionFormName_onsubmit()..FormName_onsubmit=True/False..end Function,页面会在提交前先执行语句,并根据返回值判断是否完成提交任务。
VB提供很多函数.doc

VB提供很多函数,利用函数可以简化程序,以下列出了一些常用函数:一、算术函数1、A bs(<表达式〉)返回数值表达式的绝对值。
如:Abs(-3)=32、l nt(v数值表达式〉)向下取整。
如:lnt(3.25)=3, lnt(-3.25)=-43、F ix(v数值表达式〉)取整函数。
如:Fix(3.25)=3, Fix(-3.25)=-3lnt>Fix函数返回参数的整数部分。
语法Int(number) Fix(number)必要的number参数是Double 或任何有效的数值表达式。
如果number包含Null,则返回Null。
说明Int和Fix 都会删除number 的小数部份而返冋剩下的整数。
Int和Fix的不同之处在于,如果number为负数,则Int返回小于或等于number的第一个负整数,而Fix则会返回大于或等于number的第一个负整数。
例如,Int将-8.4转换成-9,而Fix将-8.4转换成-8。
4、R ound(<数值表达式〉[,<表达式>])按指定位数四舍五入。
如:Round(3.2553z l)=3.3, Round(3.754,0)=45、s qr(<数值表达式〉)计算平方根。
如:sqr(9)=36、R nd[(number)]可选的number参数是Single或任何有效的数值表达式。
返回值如果number的值是Rnd生成小于0每次都使用number作为随机数种子得到的相同结果。
大于0序列中的下一个随机数。
等于0最近生成的数。
省略序列屮的下一个随机数。
说明Rnd函数返回小于1但大于或等于0的值。
number的值决定了Rnd生成随机数的方式。
对最初给定的种子都会生成相同的数列,因为每一次调用Rnd函数都用数列中的前一个数作为下一个数的种子。
在调用Rnd之前,先使用无参数的Randomize语句初始化随机数生成器,该生成器具有根据系统计吋器得到的种子。
为了生成某个范围内的随机整数,可使用以下公式:lnt((upperbound - lowerbound + 1) * Rnd + lowerbound)这里,upperbound是随机数范围的上限,而lowerbound则是随机数范围的下限。
VB常用函数列表

类型转换函数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值转换为双精度数11、CLng(x):把x的小数部分四舍五入转换为长整数型数12、CSng(x):把x值转换为单精度数13、Cvar(x):把x值转换为变体类型值14、VarPtr(var):取得变量var的指针2 数学函数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次方2 日期与时间函数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)2 随机数函数1、Rnd[(x)]:产生一个0~1之间的单精度随机数2、Randmize[(x)]:功能同上,不过更好2 字符串函数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$(字符串):把大写字母转换为小写字母2 窗体输入输出函数1、Print(字符串):在窗体输出字符串,可以用”&”对变量进行连接后输出2、Tab(n):把光标移到该行的n开始的位置3、Spc(n):跳过n个空格4、Cls:清除当前窗体内的显示内容5、Move 左上角x,左上角y,宽度,高度:移动窗体或控件6、InputBox(prompt,…):跳出一个数据输入窗口,返回值为该窗口的输入值7、MsgBox(msg,[type]…):跳出一个提示窗口2 文件操作函数1、Open 文件名[For方式] [Access存取类型] [锁定] AS [#]文件号[Len=记录长度]功能:为文件的输入输出分配缓冲区,并确定缓冲区所使用的存取方式说明:1) 方式:指定文件的输入输出方式,可选,默认是Random,可以是以下值a、Output:指定顺序输出方式,将覆盖原有内容b、Input:指定顺序输入方式c、Append:指定顺序输出方式,在文件未尾追加内容d、Random:指定随机存取方式,也是默认方式,在Random方式时,如果没有Access子句,则在执行Open语句时,VB将按下列顺序打开文件:读/写、只读、只写e、指定二进制文件。
vb语言函数表

返回当前系统时间
四.常用数值格式化符号(Format)
符号
含义
0
数字位。若也0对应的表达式位置上午数字,则该位显示0。
#
数字位。若表达式中的数字对应于格式中的#,则显示该数字;若无数字对应于格式中的#,则无显示。
.
小数点。
%
百分号。数值乘以10ቤተ መጻሕፍቲ ባይዱ,再按%位置在数据中插入%
,
千分位
-+ $ ( )空格
返回具有n个相同字符的字符串
Trim[$](s)
去除字符串s首尾的空格
Ucase[$](s)
将字符串s中的字母转换为大写字母
三.常用转换函数表:
内部函数
函数功能
Asc(s)
返回字符串s的首字符的ASCLL代码
Chr[$](ASCLL代码)
将ASCLL代码转换为字符
Str[$](x)
将x转换为字符串
Val(s)
常用函数表
一.常用算数函数表:
内部函数
函数功能
Abs(x)
计算x的绝对值
Atn(X)
计算x的反正切值
Cos(X)
计算x的余弦值
Exp(X)
计算e^x
Fix(X)
返回x的整数部分
Hex(X)
返回x的十六进制值
Int(X)
返回x的整数部分
Log(X)
计算自然对数Inx
Oct(X)
返回x的八进制值
Rnd(X)
返回日期表达式中所表示的日
Hour(日期表达式)
返回时间表达式中所表达的小时
Minute(日期表达式)
返回时间表达式中所表示的分
Mouth(日期表达式)
vb常用函数一览表

v b常用函数一览表 Revised by Petrel at 2021常用内部函数数学函数函数功能示例结果说明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技"。
VB常用函数大全(数学函数)

P=Replace(X,S,R)
[说明]:将字符串X中的字符串S替换为字符串R,然后返回。
[范例]:
X=”VB is very good”
P=Replace(X,good,nice)
输出结果为:P=”VB is very nice”
5. StrReverse:反转字符串
现在的编程软件像VB,C++等,大多自带功能很强的函数库,可以很省力得完成各种功能。很多时候,想不起来实现某个功能的函数或函数格式,导致编程大费周折。作为一个编程人员,我对此深有体会。因此,特地准备了几期VB常用函数的介绍,供大家学习或参考。有说的不当之处,也欢迎在本网站的论坛中提出,大家学习。
(2) 若日期D大于当月的日数,则日期从当月的日数起,向后推算D-当月日数;若小于1,则日期从1日起向前推算1-D日。
[范例]:
P=DateSerial(2000,02,02)
则结果为P=2000/02/02
4.TimeSerial函数:合并时,分,秒成为时间
[格式]:P=TimeSerial(H,M,S)
9. Tan(N) 正切函数
例:Tan(0) 结果:0
10.Atn(N) 反切函数
例:Atn(0) 结果:0
[注意]:在三角函数中,以弧度表示。
(一)字符串类函数:
1. ASC(X),Chr(X):转换字符字符码
[格式]:
P=Asc(X) 返回字符串X的第一个字符的字符码
2. Int(X),Fix(X):取X的整数值
[格式]:
P=Int(X) ' 取<=X的最大整数值
P=Fix(X) ' 取X的整数部分,直接去掉小数
VB常用函数

3.3VB的公共函数
1.数学函数
VB中常用的数学函数
2.字符函数
(1)字符串编码
在Windows采用的DBCS(Double B yte Character Set)编码方案中,一个汉字在计算机内存中占2个字节,一个西文字符(ASCII码)占1个字节,但在VB 中采用的是Unicode(ISO字符标准)来存储字符的,所有字符都占2个字节。
为方便使用,可以用StrConv函数来对Unicode 与DBCS进行转换,可以用函数Len()函数求字符串的字符数,用LenB()函数求字符串的字节数。
(2)常用的字符串函数
3.日期与时间函数
常用的日期与时间函数
增减日期函数:DateAdd(要增减日期形式,增减量,要增减的日期变量)例:计算期末考试日期:DateAdd("ww",15,#2002/3/19#)求日期之差函数:DateDiff(要间隔日期形式,日期一,日期二)例:计算距毕业天数:DateDiff("d", Now, #2005/6/30#)日期形式
4.转换函数。
vb函数大全(VBfunctionDaquan)

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.。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Log(x)
常用对数
Log(1)
0
求自然对数值
Rnd
随机产生0~1的单精度值
Int(6*Rnd)+1
1~6
要产生一个从Min到Max的整数,应使用公式Int((Max-Min+1)*Rnd+Min)
Round(x,n)
按小数位数四舍五入
Round(3.14159,3)
3.142
第2个参数为小数位数
Rtrim(" Vb技术")
" Vb技术"
Instr(x1,x2,M)
返回字符串x2在字符串x1中的位置,M=1不区分大小写,省略则区分
Instr("baBBAC","BA")
4
找不到则返回0
String(n,x)
返回由n个首字符组成的字符串
String(3,"AB")
"AAA"
Space(n)
返回n个空格
时
分
秒
数据类型转换函数
函数
功能
示例
结果
说明
Str(x)
将数值转换为字符串
Str(45.2)
"45.2"
Val(x)
将字符串中的数字转换成数值
Val("2.3ab")
Val("a23")
2.3
0
Asc(x)
求字符ASCII值
Asc("a")
97
Chr(x)
将数值(ASCII码)转换为字符
Chr(65)
Space(3)
" "
日期和时间函数
函数
功能
示例
结果
说明
Date
返回系统日期
Date
2006-9-1
(yyyy-mm-dd)
Time
返回系统时间
Time
15:45:33
(hh:mm:ss)
Now
返回系统日期和时间
Now
2006-9-1 15:45:33
(yyyy-mm-dd hh:mm:ss)
Year(c)
求日期之差函数:DateDiff(要间隔日期形式,日期一,日期二)
例:计算生日还有多少天:DateDiff("d", Now, #12/1/2006#),结果为74
函数中的“要增减日期形式”或“要间隔日期形式”可参见下表中的形式:
日期形式
yyyy
q
m
y
d
w
ww
h
n
s
意义
年
季
月
一年的天数
日
一周的天数
星期
Mid(x,n1,n2)
从x字符串左边第n1个位置开始向右取n2个字符
Mid("Vb技术",2,2)
"b技"
Left(x,n)
从x字符串左边开始取n个字符
Left("Vb技术",3)
"Vb技"
Right(X,n)
从x字符串右边开始取n个字符
Right("Vb技术",3)
"b技术"
UCase(x)
将x字符串中所有小写字母转换为大写
返回指定日期的年份
Year("2006-9-1")或
Year(#9/1/2006#)
2006
Month(c)
返回指定日期的月份
Month("2006-9-1")
9
Day(c)
返回指定日期的日子
Day("2006-9-1")
1
Weekday()
返回指定日期的星期几
Weekday("2006-9-1")
23.51255
CDbl(x)
将数值转换成双精度型
CDbl(23.5125468)
23.5125468
常用内部函数
数学函数
函数
功能
示例
结果
说明
Abs(x)
绝对值
Abs(-50.3)
50.3
Exp(x)
自然指数
Exp(2)
e*e
e(自然对数的底)的某次方
Fix(x)
取整(取参数的整数部分)
Fix(-99.8)
-99
Int(x)
取整(取小于或等于参数的最大整数)
Int(-99.8)
Int(99.8)
-100
6
星期日为1
Hour()
返回指定时间的时数
Hour("15:45:33")
15
Minute()
返回指定时间的分数
Minute(Now)
45
假定系统时间为15:45:33
增减日期函数:DateAdd(要增减日期形式,增减量,要增减的日期)
例:计算2周后的日期:DateAdd("ww",2,#9/1/2006#),结果"2006-9-15"
Sgn(x)
取参数的符号值
Sgn(8.8)
Sgn(-8.8)
Sgn(0)
1
-1
0
参数大于0,返回1
参数小于0,返回-1
参数等于0,返回0
Sin(x)
正弦
Sin(3.14159265/180*90)
1
三角函数以“弧度”为单位
Cos(x)
余弦
Cos(3.14159265/180*180)
-1
Atn(x)
"A"
CBool(x)
将数字字符串或数值转换成布尔型
CBool(1)
CBool("0")
True
False
等于0为False,不等于0为True
CDate(x)
将有效的日期字符串转换成日期
CDate(#1990,2,23#)
"1990-2-23"
CSng(x)
将数值转换成单精度型
CSng(23.5125468)
Tan(x)
计算正切
Tan(3.14159265/180*45)
1
Sqr(x)
算术平方根
Sqr(9)
3
相当于
字符串函数
函数
功能
示例
结果
说明
Len(x)
求字符串的长度(字符个数)
Len("Vb技术")
4
LenB(x)
求字符串的字节个数
LenB("Vb技术")
8
VB中采用Unicode(ISO字符标准)来存储字符,所有字符都占2个字节
UCase("Vb技术")
"VB技术"
LCase(x)
将x字符串中所有大写字母转换为小写
LCase("Vb技术")
"vb技术"
Trim(x)
去掉x字符串两边的空格
Trim(" Vb技术")
"Vb技术"
Ltrim(x)
去掉x字符串左边的空格
Ltrim(" Vb技术")
"Vb技术"
Rtrim(x)
去掉x字符串右边的空格