令牌替换
时 间:2009-05-13 22:17:45
作 者:victorduane ID:70 城市:闵行
摘 要:令牌与文本替换
正 文:
有时候我们为了一些特殊的要求把文件中的一些机密用令牌的方式来加密,但要读取的时候又要看的明白,有时候要把一些文本替换为令牌,为此提供下面的代码以供参考
?dhtokenreplace("unable to add file %1 to %2","c:\batcaa.bat","cc\aadbe")
unable to add file c:\batcaa.bat to cc\aadbe
?dhtokenreplace1("unable to add file c:\batcaa.bat to cc\aadbe","c:\batcaa.bat","cc\aadbe")
unable to add file %1 to %2
'把令牌替换为文本
Public Function dhTokenReplace(ByVal strIn As String, _
ParamArray varItems() As Variant) As String
On Error GoTo HandleErr
Dim intPos As Integer
Dim strReplace As String
Dim intI As Integer
For intI = LBound(varItems) To UBound(varItems)
strReplace = "%" & (intI + 1)
intPos = InStr(1, strIn, strReplace)
If Len(intPos) > 0 Then
strIn = Left$(strIn, intPos - 1) & _
varItems(intI) & Mid$(strIn, intPos + _
Len(strReplace))
End If
Next intI
ExitHere:
dhTokenReplace = strIn
Exit Function
HandleErr:
Select Case Err.Number
Case Else
MsgBox "Error:" & Err.Description & "(" & Err.Number & ")"
End Select
Resume ExitHere
End Function
'把文本换为令牌
Public Function dhTokenReplace1(ByVal strIn1 As String, _
ParamArray varItems1() As Variant) As String
On Error GoTo HandleErr
Dim intPos1 As Integer
Dim strReplace1 As String
Dim intI1 As Integer
For intI1 = LBound(varItems1) To UBound(varItems1)
strReplace1 = varItems1(intI1)
intPos1 = InStr(1, strIn1, strReplace1)
If Len(intPos1) > 0 Then
strIn1 = Left$(strIn1, intPos1 - 1) & _
"%" & (intI1 + 1) & Mid$(strIn1, intPos1 + _
Len(strReplace1))
End If
Next intI1
ExitHere:
dhTokenReplace1 = strIn1
Exit Function
HandleErr:
Select Case Err.Number
Case Else
MsgBox "Error:" & Err.Description & "(" & Err.Number & ")"
End Select
Resume ExitHere
End Function
Access软件网官方交流QQ群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 【Access高效办公】按日期...(06.12)
- 合并列数据到一个文本框的示例;...(05.06)
- 通过命令按钮让Access列表...(04.24)
- 统计当月之前(不含当月)的记录...(03.11)
- 【Access Inputbo...(03.03)
- 按回车键后光标移动到下一条记录...(02.12)
- 【Access Dsum示例】...(02.07)
- Access对子窗体的数据进行...(02.05)
- 【Access高效办公】上月累...(01.09)

学习心得
最新文章
- Access快速开发平台--Acc...(06.16)
- 【Access高效办公】按日期区间...(06.12)
- Access快速开发平台--生成复...(06.07)
- 仓库管理实战课程(25)-导航菜单...(06.06)
- 仓库管理实战课程(24)-库存月结...(06.05)
- 分享一个简单的X氏家谱小示例(06.04)
- 仓库管理实战课程(23)-先入先出(06.02)
- 仓库管理实战课程(22)-代理商库...(05.30)
- 仓库管理实战课程(21)-安全库存...(05.28)
- Access快速开发平台--如何添...(05.26)