by James M. Rader (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 29th November 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Parse through a text string and replace special SendKey characters with the character string that will allow the special characters to be sent
' The SendKeys function of VB will not send special characters
' as regular ASCII characters unless they are surrounded by
' the curly braces {}
'
' The special characters are: + ^ % ~ ( ) [ ] { }
'
' Copy this entire code snippet into a module in your VB
' project and then call it with the following syntax:
'
' Call SpecialCharacters(yourTextString)
Public NewTextString As String
Public Sub SpecialCharacters(OldTextString As String)
Dim x As Integer
Dim SpecChar As String
NewTextString = ""
x = 1
' Parse through the string and replace the special
' characters with the character string that will
' allow the special characters to work with SendKeys
While x < (Len(OldTextString) + 1)
SpecChar = Mid(OldTextString, x, 1)
If SpecChar = "+" Then
SpecChar = "{+}"
ElseIf SpecChar = "^" Then
SpecChar = "{^}"
ElseIf SpecChar = "%" Then
SpecChar = "{%}"
ElseIf SpecChar = "~" Then
SpecChar = "{~}"
ElseIf SpecChar = "(" Then
SpecChar = "{(}"
ElseIf SpecChar = ")" Then
SpecChar = "{)}"
ElseIf SpecChar = "[" Then
SpecChar = "{[}"
ElseIf SpecChar = "]" Then
SpecChar = "{]}"
ElseIf SpecChar = "{" Then
SpecChar = "{{}"
ElseIf SpecChar = "}" Then
SpecChar = "{}}"
ElseIf SpecChar = "^" Then
SpecChar = "{+}"
End If
NewTextString = NewTextString & SpecChar
x = x + 1
Wend
End Sub
No comments have been posted about Parse through a text string and replace special SendKey characters with the character string that w. Why not be the first to post a comment about Parse through a text string and replace special SendKey characters with the character string that w.