|
补充被调用函数一组:
-
- '************************************************************************
- '设计说明: 根据日期、时间和两组随机数生成相对较为唯一的字符串,常用于文件的非覆盖保存'程序输入:
- ' 1. circleNumber -- 循环次数
- '程序输出: 日期、时间、随机数、随机数的拼接字符串如:20110107_161003_93778_47149
- '设计人员: 刘毅(LIUYI)
- '设计时间: 2011-01-07
- '调用举例: Printer GenerateUniqueStr("30")
- '************************************************************************
- Public Function GenerateUniqueStr(circleNumber)
- If Trim(circleNumber) = "" Then
- circleNumber = randomnumber.Value(20,50)
- Else
- If circleNumber < 11 Then
- circleNumber = circleNumber + 20
- End If
- End If
-
- randomNo = randomnumber.Value(10,Abs(circleNumber))
- For i = 1 to randomNo
- randomNum1 = randomnumber.Value(10000,99999)
- randomNum2 = Int((99999-10000+1)*rnd+10000)
- Next
-
- GenerateUniqueStr = FormatDate(Now,"yyyymmdd_hh24miss")&"_"&randomNum1&"_"&randomNum2
- End Function
- '******************************************************************************
- '设计说明: (模仿PL/SQL同名函数)将字符串扩展到指定长度,用fillWithChar从左边循环填充,本函数不会截短appointedStr
- '程序输入:
- ' 1. appointedStr -- 字符串
- ' 2. appointedwidth -- 指定的长度
- ' 3. fillWithChar -- 填充字符
- '程序输出:
- '设计人员: 刘毅(LIUYI)
- '设计时间: 2011-01-04
- '调用举例: msgbox OracleLPadStr(Second(theTime), 2, "0")
- '******************************************************************************
- Function OracleLPadStr(appointedStr, appointedwidth, fillWithChar)
- OracleLPadStr = ExpandString(fillWithChar, appointedwidth - Len(appointedStr)) & appointedStr
- End Function
- '******************************************************************************
- '设计说明: (模仿PL/SQL同名函数)将字符串扩展到指定长度,用fillWithChar从左边循环填充,本函数不会截短appointedStr
- '程序输入:
- ' 1. appointedStr -- 字符串
- ' 2. appointedwidth -- 指定的长度
- ' 3. fillWithChar -- 填充字符
- '程序输出:
- '设计人员: 刘毅(LIUYI)
- '设计时间: 2011-01-04
- '调用举例: msgbox OracleLPadStr(Second(theTime), 2, "0")
- '******************************************************************************
- Function OracleRPadStr(appointedStr, appointedwidth, fillWithChar)
- OracleRPadStr = appointedStr & ExpandString(fillWithChar, appointedwidth - Len(appointedStr))
- End Function
- '******************************************************************************
- '设计说明: 将appointedStr反复叠加,使其长度扩展(或缩小)到appointedwidth
- '程序输入:
- ' 1. appointedStr -- 字符串
- ' 2. appointedwidth -- 指定的长度
- '程序输出:
- '设计人员: 刘毅(LIUYI)
- '设计时间: 2011-01-04
- '调用举例: ExpandString("bye",7) 返回 byebyeb ; ExpandString("bye",2)返回 by
- '******************************************************************************
- Private Function ExpandString(appointedStr, appointedwidth)
- Dim width0, repeat_times, reminder, i, result
-
- If appointedwidth <= 0 Then
- ExpandString = ""
- Exit Function
- End If
-
- width0 = Len(appointedStr)
- repeat_times = appointedwidth \ width0
- reminder = appointedwidth Mod width0
-
- For i = 1 To repeat_times
- result = result & appointedStr
- Next
-
- result = result & Left(appointedStr, reminder)
- ExpandString = result
- End Function
复制代码 |
|