|
- ==============================
- 字符串系列函数
- 1.取出文本中某字符串的左边的所有文本
- //函数代码
- Function 取文本左边(源文本, 查找文本)
- 位置 = InStr(源文本, 查找文本)
- 取文本左边 = Left(源文本, 位置 - 1)
- End Function
- //测试代码
- TracePrint 取文本左边("按键你好|呵呵", "|")
- 2.取出文本中某字符串的右边的所有文本
- //函数代码
- Function 取文本右边(源文本, 查找文本)
- 位置 = InStr(源文本, 查找文本)
- 取文本右边 = Right(源文本, Len(源文本)-位置)
- End Function
- //测试代码
- TracePrint 取文本右边("按键你好|呵呵", "|")
- 3.取出文本中两个字符串中间的文本
- 函数代码//
- Function 取文本中间(源文本, 左边文本, 右边文本)
- 左边位置 = InStr(源文本, 左边文本)
- 右边位置 = InStrRev(源文本, 右边文本)
- 宽度 = 右边位置 - 左边位置-1
- 取文本中间 = MID(源文本, 左边位置+1, 宽度)
- End Function
- 测试代码//
- TracePrint 取文本中间("你好A按键B精灵","A","B")
- 4.判断文本是否重复
- ////参数一: 所有文本。 参数二:待查询的文本
- ////返回:重复返回1,不重复返回2
- Function 文本_是否重复(参数_文本, 参数_查询字符)
- If Instr(参数_文本, 参数_查询字符)>0 Then
- 文本_是否重复 = 1
- Else
- 文本_是否重复 = 0
- End If
- End Function
- /////////测试代码
- TracePrint 文本_是否重复("你好", "你")
- TracePrint 文本_是否重复("你好", "按键")
- 5.分割出单个字符
- /////////参数一:待分割的文本
- /////////返回:含分隔符的文本
- Function 文本_逐字分割(参数_待分割)
- For i = 1 To len(参数_待分割)
- 文本_逐字分割 = 文本_逐字分割 & mid(参数_待分割, i, 1) & "‰"
- Next
- End Function
- /////////测试代码
- 文本 = 文本_逐字分割("你好。+-2017aabbcc")
- 数组 = split(文本, "‰")
- For i = 0 To UBound(数组) - 1
- TracePrint "当前位置:" & i + 1 & "->" & 数组(i)
- Next
- ---------------------------------------------------------------
- 密码输入类【前台】
- str = "abcABC..!!@@#¥"
- For i = 1 To len(str)
- If asc(mid(str, i, 1)) >= 35 and asc(mid(str, i, 1)) <= 37 Then
- KeyDown 16, 1
- KeyPress asc(mid(str, i, 1)) + 16,1
- KeyUp 16, 1
- ElseIf asc(mid(str, i, 1)) >= 123 and asc(mid(str, i, 1)) <= 125 Then
- KeyDown 16, 1
- KeyPress asc(mid(str, i, 1)) + 96,1
- KeyUp 16, 1
- ElseIf asc(mid(str, i, 1)) >= 62 and asc(mid(str, i, 1)) <= 63 Then
- KeyDown 16, 1
- KeyPress asc(mid(str, i, 1)) + 128,1
- KeyUp 16, 1
- ElseIf asc(mid(str, i, 1)) >= 65 and asc(mid(str, i, 1)) <= 90 Then
- KeyDown 16, 1
- KeyPress asc(mid(str, i, 1)),1
- KeyUp 16, 1
- ElseIf asc(mid(str, i, 1)) = 33 Then
- KeyDown 16, 1
- KeyPress 49,1
- KeyUp 16, 1
- ElseIf asc(mid(str, i, 1)) = 64 Then
- KeyDown 16, 1
- KeyPress 50,1
- KeyUp 16, 1
- ElseIf asc(mid(str, i, 1)) = 94 Then
- KeyDown 16, 1
- KeyPress 54,1
- KeyUp 16, 1
- ElseIf asc(mid(str, i, 1)) = 38 Then
- KeyDown 16, 1
- KeyPress 55,1
- KeyUp 16, 1
- ElseIf asc(mid(str, i, 1)) = 42 Then
- KeyDown 16, 1
- KeyPress 56,1
- KeyUp 16, 1
- ElseIf asc(mid(str, i, 1)) = 41 Then
- KeyDown 16, 1
- KeyPress 48,1
- KeyUp 16, 1
- ElseIf asc(mid(str, i, 1)) = 40 Then
- KeyDown 16, 1
- KeyPress 57,1
- KeyUp 16, 1
- ElseIf asc(mid(str, i, 1)) = 95 Then
- KeyDown 16, 1
- KeyPress 189,1
- KeyUp 16, 1
- ElseIf asc(mid(str, i, 1)) = 43 Then
- KeyDown 16, 1
- KeyPress 187,1
- KeyUp 16, 1
- ElseIf asc(mid(str, i, 1)) = 60 Then
- KeyDown 16, 1
- KeyPress 188,1
- KeyUp 16, 1
- ElseIf asc(mid(str, i, 1)) = 126 Then
- KeyDown 16, 1
- KeyPress 192,1
- KeyUp 16, 1
- ElseIf asc(mid(str, i, 1)) = -23644 or asc(mid(str, i, 1)) = -24089 Then ///¥ $
- KeyDown 16, 1
- KeyPress 52,1
- KeyUp 16, 1
- ElseIf asc(mid(str, i, 1)) >= 97 and asc(mid(str, i, 1)) <= 122 Then
- KeyPress asc(mid(str, i, 1)) - 32,1
- ElseIf asc(mid(str, i, 1)) >= 44 and asc(mid(str, i, 1)) <= 47 Then
- KeyPress asc(mid(str, i, 1)) + 144,1
- ElseIf asc(mid(str, i, 1)) >= 91 and asc(mid(str, i, 1)) <= 93 Then
- KeyPress asc(mid(str, i, 1)) + 128,1
- ElseIf asc(mid(str, i, 1)) = 96 Then
- KeyPress 192,1
- ElseIf asc(mid(str, i, 1)) = 61 Then
- KeyPress 187,1
- ElseIf asc(mid(str, i, 1)) = 59 Then
- KeyPress 186,1
- ElseIf asc(mid(str, i, 1)) = 39 Then
- KeyPress 222,1
- Else
- KeyPress asc(mid(str, i, 1)),1
- End If
- Delay 10
- Next
- -------------------------------------------------------------------------------------------
- 计时的信息框
- Declare Function MessageBoxTimeout Lib "user32.dll" Alias "MessageBoxTimeoutA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long, ByVal wlange As Long, ByVal dwTimeout As Long) As Long
- hwnd = Plugin.Window.MousePoint()
- ////////1000表示1s
- MessageBoxTimeout 0, "你好,欢迎使用", "提示", 0, 1, 1000
- -------------------------------------------------------------------------------------------
- 复制Word中的图片
- lsFileName = "C:\1.doc"'请将此处替换为word文档地址
- Set wordObj = CreateObject("Word.Application")'调用word应用类
- wordObj.Visible = False'设置为不可见
- wordObj.Documents.Open (lsFileName)'打开word文档
- wordobj.Selection.WholeStory
- wordobj.Selection.Copy
- wordObj.Quit '退出word应用类
- Set wordObj = Nothing'销毁word应用类
- ==============================
复制代码
|
|