Function Replace(fstr As String,rstr As String,tstr As String) As String
//r5适用
'''''''''''''''''''''''
'fstr 要处理的字符串
'rstr 要替换的字符串
'tstr 字符串替换目标
''''''''''''''''''''''''
While Instr(fstr,rstr)>0
strtemp=Strleft(fstr,rstr)+tstr+Strright(fstr,rstr)
fstr=strtemp
Wend
Replace=fstr
End Function
Function Split(strSoucer As String,sp As String) As Variant
//r5适用
Dim y() As String
Dim strtemp As String,i As Integer
i=0
While Instr(strSoucer,sp)>0 And strSoucer<>""
Redim Preserve y(i)
strtemp=Strleft(strSoucer,sp)
y(i)=strtemp
strSoucer=Strright(strSoucer,sp)
i=i+1
Wend
Redim Preserve y(i)
y(i)=strSoucer
Split=y
End Function
Sub getV()
'lotus script 文件操作
Dim fileNum As Integer
Dim fileName As String
fileNum% = Freefile()
fileName$ = "D:/nluserenpass.ini"
Open fileName$ For Random As fileNum%
Dim rec As String
Seek fileNum%, 1
Do While Not Eof(fileNum%)
Get #fileNum%, , rec
Print rec
Loop
Close fileNum%
End Sub
Function GetIniValue(section As String,key As String,filepath As String) As String
''''''''''''''''''''''''''''
'ini 文件操作,引用此函数注意代理权限最低为2
'获取ini文件中某一项值
''''''''''''''''''''''''''''
On Error Goto errorH
Dim session As New NotesSession
Dim stream As NotesStream
Set stream=session.CreateStream
Dim flag_isin_sec As Boolean,flag_geted As Boolean
Dim rtstr As String
flag_isin_sec=False
flag_geted=False
section="["+section+"]"
If Not stream.Open(filepath, "GB2312") Then
Messagebox filepath,, "Open failed"
Exit Function
End If
key=key+"="
While Not stream.IsEOS And Not flag_geted
buffer$ = Trim(stream.ReadText(STMREAD_LINE,EOL_PLATFORM))
buffer$=Replace(Replace(Trim(buffer$),Chr(13),""),Chr(10),"")
If flag_isin_sec Then
'首先查找 section 直到下个section出现
If Left(buffer$,1)="[" And Right(buffer$,1)="]" Then
flag_isin_sec=False
End If
End If
If buffer$=section Then
flag_isin_sec=True
End If
If flag_isin_sec Then
If Instr(buffer$,key)>0 Then
rtstr=Strright(buffer$,"=")
flag_geted=True
End If
End If
Wend
stream.Close
GetIniValue=Replace(Replace(Trim(rtstr),Chr(13),""),Chr(10),"")
Exit Function
errorH:
Dim sError As New NotesSession
Dim dbError As NotesDatabase
Dim agError As NotesAgent
Set agError=sError.CurrentAgent
Set dbError=sError.CurrentDatabase
Msgbox dbError.title+"("+dbError.FilePath+")::"+agError.Name+_
"->LSINI->GetIniValue->Error="+Error+":Erl="+Cstr(Erl)
Exit Function
End Function