PDA

View Full Version : Array takes out the parentheses



bryVA
06-29-2009, 11:03 AM
Hello,

I have the following code that will take a large amount of data in a textbox and place it in a database. The issue is that if I place any parentheses in the textbox when it loops through the array it takes the parentheses out. Any idea why?

MAPDocuments = "Received a request from " & TextBox9.Value & " " & TextBox10.Value & " " & TextBox11.Value & "to Send a " & GetRegData("FormType") & " to " & sentletto & ". Sending letter." & vbCrLf

Const StrLen = 127

Dim NumElems As Integer
Dim Temp() As String

NumElems = (Len(MAPDocuments) / StrLen) + 1
ReDim Temp(1 To NumElems) As String

' Build the Temp array
For i = 1 To NumElems
Temp(i) = Mid(MAPDocuments, ((i - 1) * StrLen) + 1, StrLen)
Next i



On Error Resume Next

AppActivate "MAPD", True
Application.SendKeys Temp, True
Else
End If

The reason why I go through the array is when I try to send more than 250 charecters in a variable it doesn't pull all the data over into the database.

Bob Phillips
07-01-2009, 02:37 AM
Code seems incomplete. Where is the IF for example?

bryVA
07-01-2009, 06:08 AM
There is an If statement that just checks to see if a checkbox has been checked if so then perform the rest that is there. The If statement works just fine and the rest does as well except it takes the parentheses out and I can't figure out why.

mikerickson
07-01-2009, 06:15 AM
From VBEditor Help:


SendKeys statement:
...
The plus sign (+), caret (^), percent sign (%), tilde (~), and parentheses ( ) have special meanings to SendKeys. To specify one of these characters, enclose it within braces ({}). For example, to specify the plus sign, use {+}. Brackets ([ ]) have no special meaning to SendKeys, but you must enclose them in braces. In other applications, brackets do have a special meaning that may be significant when dynamic data exchange (DDE) occurs. To specify brace characters, use {{} and {}}.

Adding the lines:
MAPDocuments = Application.Substitute(MAPDocuments,"(","{(}")
MAPDocuments = Application.Substitute(MAPDocuments,")","{)}")
might set things right.