`
ktc7000
  • 浏览: 33474 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

QTP中字符串替换函数

阅读更多
Function Replace_ex (ExPression, Find, Replace_tmp)
Dim i, j, s , s1
    s = LCase(ExPression) '统一转换为小写,表示不区分大小写
    Find = LCase(Find) '同上
    i = 1
    Do While InStr(i, s, Find, vbBinaryCompare) > 0 '查找
        j = InStr(i, s, Find, vbBinaryCompare)
        s1 = s1 + Mid(ExPression, i, j - i) + Replace_tmp '替换
        i = j + Len(Find)
    Loop
    If i <= Len(ExPression) Then s1 = s1 + Mid(ExPression, i)
    Replace_ex = s1 '输出
End Function
分享到:
评论
2 楼 ktc7000 2012-12-27  
'Declare FindWindow method
'Extern.Declare micHwnd, "FindWindow", "user32.dll", "FindWindowA", micString, micString
'
'Declare SetWindowText method
'Extern.Declare micLong, "SetWindowText", "user32.dll", "SetWindowTextA", micHwnd, micString

'Change the title of the notepad window
'res = Extern.SetWindowText(hwnd, "SIAdd")
1 楼 ktc7000 2012-12-26  
Dim xml_tmp,xml_boss,cdata_left,cdata_right
Cont_left="<SvcCont>"
Cont_right="</SvcCont>"
cdata_left="<SvcCont><![CDATA[<?xml version="+Chr(34)+"1.0"+Chr(34)+" encoding="+Chr(34)+"UTF-8"+Chr(34)+"?> "
cdata_right="]]></SvcCont>"
xml_tmp=XMLWarehouse("SIAdd")
xml_tmp=Replace_ex(xml_tmp, Cont_left, cdata_left)
xml_boss=Replace_ex(xml_tmp, Cont_right, cdata_right)

相关推荐

Global site tag (gtag.js) - Google Analytics