asp 类型转换函数大全第2/2页

 更新时间:2008年10月20日 23:01:33   作者:  
asp 类型转换的实现函数

IsObject() 
 
函数判断一对象是否为对象, | 布尔值. 
 
表达式 IsObject(expression) 
 
实例: <% 
 
Set con = Server.CreateObject("ADODB.Connection") 
 
response.write IsObject(con) 
 
%> 
 
| 结果: True 
 
 
Lbound() 
 
函数 | 指定数组维的最小可用下标. 
 
表达式 Lbound(arrayname [, dimension]) 
 
实例: <% 
 
I = Array("Monday","Tuesday","Wednesday") 
 
response.write Lbound(I) 
 
%> 
 
| 结果: 0 
 
 
Lcase() 
 
函数 | 字符串的小写形式 
 
表达式 Lcase(string) 
 
实例: <% 
 
strTest = "This is a test!" 
 
response.write Lcase(strTest) 
 
%> 
 
| 结果: this is a test! 
 
 
Left() 
 
函数 | 字符串左边第length个字符以前的字符(含第length个字符). 
 
表达式 Left(string, length) 
 
实例: <% 
 
strTest = "This is a test!" 
 
response.write Left(strTest, 3) 
 
%> 
 
| 结果: Thi 
 
 
Len() 
 
函数 | 字符串的长度. 
 
表达式 Len(string | varName) 
 
实例: <% 
 
strTest = "This is a test!" 
 
response.write Len(strTest) 
 
%> 
 
| 结果: 15 
 
 
Ltrim() 
 
函数去掉字符串左边的空格. 
 
表达式 Ltrim(string) 
 
实例: <% 
 
strTest = " This is a test!" 
 
response.write Ltrim(strTest) 
 
%> 
 
| 结果: This is a test! 
 
 
Mid() 
 
函数 | 特定长度的字符串(从start开始,长度为length). 
 
表达式 Mid(string, start [, length]) 
 
实例: <% 
 
strTest = "This is a test! Today is Monday." 
 
response.write Mid(strTest, 17, 5) 
 
%> 
 
| 结果: Today 
 
 
Minute() 
 
函数 | 时间的分钟. 
 
表达式 Minute(time) 
 
实例: <%=Minute(#12:45:32 PM#)%> 
 
| 结果: 45 
 
 
Month() 
 
函数 | 日期. 
 
表达式 Month(date) 
 
实例: <%=Month(#08/04/99#)%> 
 
| 结果: 8 
 
 
MonthName() 
 
函数 | 指定月份 
 
表达式 MonthName(month, [, Abb]) 
 
实例: <%=MonthName(Month(#08/04/99#))%> 
 
| 结果: August 
 
 
Now() 
 
函数 | 系统时间 
 
表达式 Now() 
 
实例: <%=Now%> 
 
| 结果: 9/9/00 9:30:16 AM 
 
 
Right() 
 
函数 | 字符串右边第length个字符以前的字符(含第length个字符). 
 
表达式 Right(string, length) 
 
实例: <% 
 
strTest = "This is an test!" 
 
response.write Right(strTest, 3) 
 
%> 
 
| 结果: st! 
 
 
Rnd() 
 
函数产生一个随机数. 
 
表达式 Rnd [ (number) ] 
 
实例: <% 
 
Randomize()
response.write RND() 
 
%> 
 
| 结果: 任何一个在0 到 1 之间的数
等待 发表于 2008-2-25 17:08
instr 查找 索引 函数
instr 函数
表达式:
InStr([start, ]string1, string2[, compare])
描述:
start
可选参数。为数值表达式,设置每次搜索的起点。如果省略,将从第一个字符的位置开始。如果 start 包含 Null,将发生错误。如果指定了 compare 参数,则一定要有 start 参数。
string1
必要参数。接受搜索的字符串表达式。
string2
必要参数。被搜索的字符串表达式。
Compare
可选参数。指定字符串比较。如果 compare 是 Null,将发生错误。如果省略 compare,Option Compare 的设置将决定比较的类型。
compare 参数设置为:
常数

描述
vbUseCompareOption
-1
使用Option Compare 语句设置执行一个比较。
vbBinaryCompare
0
执行一个二进制比较。
vbTextCompare
1
执行一个按照原文的比较。
vbDatabaseCompare
2
仅适用于Microsoft Access,执行一个基于数据库中信息的比较。
返回值
返回0、1、2、-1或Null等。
异常/错误

描述InStr([start, ]string1, string2[, compare])
返回指定一字符串在另一字符串中最先出现的位置。在字符串string1中,从start开始找string2,省略start时从string1头开始找。找不到时,函数值为0。
如果
InStr返回
string1 为零长度
0
string1 为 Null
Null
string2 为零长度
Start
string2 为 Null
Null
string2 找不到
0
在 string1 中找到string2
找到的位置
start > string2
0
示例
本示例使用 InStr 函数来查找某字符串在另一个字符串中首次出现的位置。
Dim SearchString, SearchChar, MyPos
SearchString ="XXpXXpXXPXXP" ' 被搜索的字符串。
SearchChar = "P" ' 要查找字符串 "P"。
' 从第四个字符开始,以文本比较的方式找起。返回值为 6(小写 p)。
' 小写 p 和大写 P 在文本比较下是一样的。
MyPos = Instr(4, SearchString, SearchChar, 1)
' 从第一个字符开使,以二进制比较的方式找起。返回值为 9(大写 P)。
' 小写 p 和大写 P 在二进制比较下是不一样的。
MyPos = Instr(1, SearchString, SearchChar, 0)
' 缺省的比对方式为二进制比较(最后一个参数可省略)。
MyPos = Instr(SearchString, SearchChar) ' 返回 9。
MyPos = Instr(1, SearchString, "W") ' 返回 0。

相关文章

最新评论