467,145 Members | 954 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,145 developers. It's quick & easy.

Sending an "(" with sendkeys

I have a procedure that needs to put characters into the current insertion
point of a textbox. This insertion point is not necessarily the end of the
current string so textbox1.text &= "?" won't do.

I have found that using sendkeys does the trick:

Private Sub UserControl11_buttonpress(ByVal text As String) Handles
UserControl11.buttonpress
System.Windows.Forms.SendKeys.Send(text)
End Sub

However if the parameter "text" happens to be "(" or ")", I get the
following error:

An unhandled exception of type 'System.ArgumentException' occurred in
system.windows.forms.dll
Additional information: Group are delimiters not balanced.

It looks like sendkeys is evaluating (text) rather that simply mimicking a
"(" key press.

There does not appear to be a special sendkeys code for parenthesis and
chr(40 or 41) doesn't work.

How do I handle this special case?
--
mark
Nov 21 '05 #1
  • viewed: 22631
Share:
3 Replies
<mdsn>
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
"{+}". To specify brace characters, use "{{}" and "{}}". Brackets ([ ]) have
no special meaning to SendKeys, but you must enclose them in braces.
</msdn>

"mark" <ma**@discussions.microsoft.com> wrote in message
news:E6**********************************@microsof t.com...
I have a procedure that needs to put characters into the current insertion
point of a textbox. This insertion point is not necessarily the end of the
current string so textbox1.text &= "?" won't do.

I have found that using sendkeys does the trick:

Private Sub UserControl11_buttonpress(ByVal text As String) Handles
UserControl11.buttonpress
System.Windows.Forms.SendKeys.Send(text)
End Sub

However if the parameter "text" happens to be "(" or ")", I get the
following error:

An unhandled exception of type 'System.ArgumentException' occurred in
system.windows.forms.dll
Additional information: Group are delimiters not balanced.

It looks like sendkeys is evaluating (text) rather that simply mimicking a
"(" key press.

There does not appear to be a special sendkeys code for parenthesis and
chr(40 or 41) doesn't work.

How do I handle this special case?
--
mark
Nov 21 '05 #2

Shiva,

Thank you, you are a wizard.

I have an extensive library of vb.net references, but they don't include
this important level of detail. Can you recommend a reference that does cover
this type of information?


"Shiva" wrote:
<mdsn>
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
"{+}". To specify brace characters, use "{{}" and "{}}". Brackets ([ ]) have
no special meaning to SendKeys, but you must enclose them in braces.
</msdn>

"mark" <ma**@discussions.microsoft.com> wrote in message
news:E6**********************************@microsof t.com...
I have a procedure that needs to put characters into the current insertion
point of a textbox. This insertion point is not necessarily the end of the
current string so textbox1.text &= "?" won't do.

I have found that using sendkeys does the trick:

Private Sub UserControl11_buttonpress(ByVal text As String) Handles
UserControl11.buttonpress
System.Windows.Forms.SendKeys.Send(text)
End Sub

However if the parameter "text" happens to be "(" or ")", I get the
following error:

An unhandled exception of type 'System.ArgumentException' occurred in
system.windows.forms.dll
Additional information: Group are delimiters not balanced.

It looks like sendkeys is evaluating (text) rather that simply mimicking a
"(" key press.

There does not appear to be a special sendkeys code for parenthesis and
chr(40 or 41) doesn't work.

How do I handle this special case?
--
mark

Nov 21 '05 #3
Mark,

MSDN (online or the locally installable library) is the ultimate resource
for this type of documentation details. In fact, .NET SDK and Visual Studio
..NET themselves come with full .NET class library documentation.

Hope that helps.

"mark" <ma**@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...

Shiva,

Thank you, you are a wizard.

I have an extensive library of vb.net references, but they don't include
this important level of detail. Can you recommend a reference that does
cover
this type of information?


"Shiva" wrote:
<mdsn>
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
"{+}". To specify brace characters, use "{{}" and "{}}". Brackets ([ ]) have no special meaning to SendKeys, but you must enclose them in braces.
</msdn>

"mark" <ma**@discussions.microsoft.com> wrote in message
news:E6**********************************@microsof t.com...
I have a procedure that needs to put characters into the current insertion
point of a textbox. This insertion point is not necessarily the end of the
current string so textbox1.text &= "?" won't do.

I have found that using sendkeys does the trick:

Private Sub UserControl11_buttonpress(ByVal text As String) Handles
UserControl11.buttonpress
System.Windows.Forms.SendKeys.Send(text)
End Sub

However if the parameter "text" happens to be "(" or ")", I get the
following error:

An unhandled exception of type 'System.ArgumentException' occurred in
system.windows.forms.dll
Additional information: Group are delimiters not balanced.

It looks like sendkeys is evaluating (text) rather that simply mimicking a
"(" key press.

There does not appear to be a special sendkeys code for parenthesis and
chr(40 or 41) doesn't work.

How do I handle this special case?
--
mark

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Pete | last post: by
2 posts views Thread by Phil Galey | last post: by
reply views Thread by pigge79@yahoo.com | last post: by
5 posts views Thread by =?Utf-8?B?U3JpbWFu?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.