472,122 Members | 1,507 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,122 software developers and data experts.

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
3 23907
<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
5 posts views Thread by =?Utf-8?B?U3JpbWFu?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.