473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Isn't there a more DotNet approach to comparing a character to see if it's a CR.?

Below is the result of the wizard conversion from VB6.

Looking at the Help doc I can find an example that uses Chaw()

If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
e.Handled = True
End If

But isn't there a more DotNet approach to comparing a character to see if
it's a CR.?

How would you do this?

Thanks

Private Sub ComboBoxFindStr_KeyPress(ByVal ...snip

Dim lKeyAscii As Short = Asc(e.KeyChar)

'make CR work like TAB

If lKeyAscii = 13 Then

System.Windows.Forms.SendKeys.Send("{TAB}")

lKeyAscii = 0

End If

If lKeyAscii = 0 Then

e.Handled = True

End If

End Sub
Nov 21 '05 #1
20 1458
Hows this?

Private Sub ComboBoxFindStr_KeyPress(ByVal ...snip
Dim lKeyAscii As Short = Asc(e.KeyChar)

'make CR work like TAB
If lKeyAscii.Equals(13) Then
System.Windows.Forms.SendKeys.Send("{TAB}")
lKeyAscii = 0
End If

'flag as handled is key is ASCII 0
e.Handled = lKeyAscii.Equals(0)

End Sub


Nov 21 '05 #2
Hows this?

Private Sub ComboBoxFindStr_KeyPress(ByVal ...snip
Dim lKeyAscii As Short = Asc(e.KeyChar)

'make CR work like TAB
If lKeyAscii.Equals(13) Then
System.Windows.Forms.SendKeys.Send("{TAB}")
lKeyAscii = 0
End If

'flag as handled is key is ASCII 0
e.Handled = lKeyAscii.Equals(0)

End Sub


Nov 21 '05 #3
JM

There are a lot, however for me is this (without the namespace) the nicest
dotNet one.

Cor
Nov 21 '05 #4
JM

There are a lot, however for me is this (without the namespace) the nicest
dotNet one.

Cor
Nov 21 '05 #5
" Just Me" <gr****@a-znet.com> schrieb:
Looking at the Help doc I can find an example that uses Chaw()

If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
e.Handled = True
End If

But isn't there a more DotNet approach to comparing a character to see if
it's a CR.?


It's a more VB.NET approach:

\\\
If e.KeyChar = ControlChars.Cr Then
...
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #6
" Just Me" <gr****@a-znet.com> schrieb:
Looking at the Help doc I can find an example that uses Chaw()

If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
e.Handled = True
End If

But isn't there a more DotNet approach to comparing a character to see if
it's a CR.?


It's a more VB.NET approach:

\\\
If e.KeyChar = ControlChars.Cr Then
...
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #7
I do have to convert to a number and compare to 13?
I was hoping I could do something like

if e.KeyChar = somethin.CR then

I like the .Equals - I'm going to try to remember to use that.

Thanks


"Noozer" <do*******@me.here> wrote in message
news:Ob*************@TK2MSFTNGP11.phx.gbl...
Hows this? IS THIS OK - ANY REASON TO SET Handled TO false?
Private Sub ComboBoxFindStr_KeyPress(ByVal ...snip
Dim lKeyAscii As Short = Asc(e.KeyChar)

'make CR work like TAB
If lKeyAscii.Equals(13) Then
System.Windows.Forms.SendKeys.Send("{TAB}")
'''lKeyAscii = 0
e.Handled = true
End If

'flag as handled is key is ASCII 0
'''' e.Handled = lKeyAscii.Equals(0)

End Sub

Nov 21 '05 #8
I do have to convert to a number and compare to 13?
I was hoping I could do something like

if e.KeyChar = somethin.CR then

I like the .Equals - I'm going to try to remember to use that.

Thanks


"Noozer" <do*******@me.here> wrote in message
news:Ob*************@TK2MSFTNGP11.phx.gbl...
Hows this? IS THIS OK - ANY REASON TO SET Handled TO false?
Private Sub ComboBoxFindStr_KeyPress(ByVal ...snip
Dim lKeyAscii As Short = Asc(e.KeyChar)

'make CR work like TAB
If lKeyAscii.Equals(13) Then
System.Windows.Forms.SendKeys.Send("{TAB}")
'''lKeyAscii = 0
e.Handled = true
End If

'flag as handled is key is ASCII 0
'''' e.Handled = lKeyAscii.Equals(0)

End Sub

Nov 21 '05 #9
what I was looking for
Thanks

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:e$**************@TK2MSFTNGP15.phx.gbl...
" Just Me" <gr****@a-znet.com> schrieb:
Looking at the Help doc I can find an example that uses Chaw()

If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
e.Handled = True
End If

But isn't there a more DotNet approach to comparing a character to see if
it's a CR.?


It's a more VB.NET approach:

\\\
If e.KeyChar = ControlChars.Cr Then
...
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #10
what I was looking for
Thanks

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:e$**************@TK2MSFTNGP15.phx.gbl...
" Just Me" <gr****@a-znet.com> schrieb:
Looking at the Help doc I can find an example that uses Chaw()

If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
e.Handled = True
End If

But isn't there a more DotNet approach to comparing a character to see if
it's a CR.?


It's a more VB.NET approach:

\\\
If e.KeyChar = ControlChars.Cr Then
...
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #11
Cor, Thanks for the comment

"Cor Ligthert" <no************@planet.nl> wrote in message
news:ep*************@TK2MSFTNGP15.phx.gbl...
JM

There are a lot, however for me is this (without the namespace) the nicest
dotNet one.

Cor

Nov 21 '05 #12
Cor, Thanks for the comment

"Cor Ligthert" <no************@planet.nl> wrote in message
news:ep*************@TK2MSFTNGP15.phx.gbl...
JM

There are a lot, however for me is this (without the namespace) the nicest
dotNet one.

Cor

Nov 21 '05 #13
Just Me,
As Herfried suggests, I would use ControlChars.CR:
If e.KeyChar = ControlChars.CR Then
System.Windows.Forms.SendKeys.Send("{TAB}") Rather then use SendKeys.Send to tab to the next control, you should be able
to use Control.SelectNextControl to tab to the next control.

Me.SelectNextControl(ComboBoxFindStr, True, True, True, True)

If you are using the same handler for multiple controls, you could use
something like:

Me.SelectNextControl(DirectCast(sender, Control), True, True,
True, True)

Hope this helps
Jay
" Just Me" <gr****@a-znet.com> wrote in message
news:uw**************@TK2MSFTNGP11.phx.gbl... Below is the result of the wizard conversion from VB6.

Looking at the Help doc I can find an example that uses Chaw()

If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
e.Handled = True
End If

But isn't there a more DotNet approach to comparing a character to see if
it's a CR.?

How would you do this?

Thanks

Private Sub ComboBoxFindStr_KeyPress(ByVal ...snip

Dim lKeyAscii As Short = Asc(e.KeyChar)

'make CR work like TAB

If lKeyAscii = 13 Then

System.Windows.Forms.SendKeys.Send("{TAB}")

lKeyAscii = 0

End If

If lKeyAscii = 0 Then

e.Handled = True

End If

End Sub

Nov 21 '05 #14
Just Me,
As Herfried suggests, I would use ControlChars.CR:
If e.KeyChar = ControlChars.CR Then
System.Windows.Forms.SendKeys.Send("{TAB}") Rather then use SendKeys.Send to tab to the next control, you should be able
to use Control.SelectNextControl to tab to the next control.

Me.SelectNextControl(ComboBoxFindStr, True, True, True, True)

If you are using the same handler for multiple controls, you could use
something like:

Me.SelectNextControl(DirectCast(sender, Control), True, True,
True, True)

Hope this helps
Jay
" Just Me" <gr****@a-znet.com> wrote in message
news:uw**************@TK2MSFTNGP11.phx.gbl... Below is the result of the wizard conversion from VB6.

Looking at the Help doc I can find an example that uses Chaw()

If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
e.Handled = True
End If

But isn't there a more DotNet approach to comparing a character to see if
it's a CR.?

How would you do this?

Thanks

Private Sub ComboBoxFindStr_KeyPress(ByVal ...snip

Dim lKeyAscii As Short = Asc(e.KeyChar)

'make CR work like TAB

If lKeyAscii = 13 Then

System.Windows.Forms.SendKeys.Send("{TAB}")

lKeyAscii = 0

End If

If lKeyAscii = 0 Then

e.Handled = True

End If

End Sub

Nov 21 '05 #15
Another one:
If e.KeyChar = VbCr Then
...
End If

Nov 21 '05 #16
Another one:
If e.KeyChar = VbCr Then
...
End If

Nov 21 '05 #17
shortest
thanks

"Rulin Hong" <Ru*******@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
Another one:
If e.KeyChar = VbCr Then
...
End If

Nov 21 '05 #18
shortest
thanks

"Rulin Hong" <Ru*******@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
Another one:
If e.KeyChar = VbCr Then
...
End If

Nov 21 '05 #19

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:en**************@TK2MSFTNGP14.phx.gbl...
Just Me,
As Herfried suggests, I would use ControlChars.CR:
If e.KeyChar = ControlChars.CR Then
System.Windows.Forms.SendKeys.Send("{TAB}")

Rather then use SendKeys.Send to tab to the next control, you should be
able to use Control.SelectNextControl to tab to the next control.

Me.SelectNextControl(ComboBoxFindStr, True, True, True, True)

If you are using the same handler for multiple controls, you could use
something like:

Me.SelectNextControl(DirectCast(sender, Control), True, True,
True, True)

Hope this helps
Jay


Thanks, I'll look check this out.



" Just Me" <gr****@a-znet.com> wrote in message
news:uw**************@TK2MSFTNGP11.phx.gbl...
Below is the result of the wizard conversion from VB6.

Looking at the Help doc I can find an example that uses Chaw()

If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
e.Handled = True
End If

But isn't there a more DotNet approach to comparing a character to see if
it's a CR.?

How would you do this?

Thanks

Private Sub ComboBoxFindStr_KeyPress(ByVal ...snip

Dim lKeyAscii As Short = Asc(e.KeyChar)

'make CR work like TAB

If lKeyAscii = 13 Then

System.Windows.Forms.SendKeys.Send("{TAB}")

lKeyAscii = 0

End If

If lKeyAscii = 0 Then

e.Handled = True

End If

End Sub


Nov 21 '05 #20

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:en**************@TK2MSFTNGP14.phx.gbl...
Just Me,
As Herfried suggests, I would use ControlChars.CR:
If e.KeyChar = ControlChars.CR Then
System.Windows.Forms.SendKeys.Send("{TAB}")

Rather then use SendKeys.Send to tab to the next control, you should be
able to use Control.SelectNextControl to tab to the next control.

Me.SelectNextControl(ComboBoxFindStr, True, True, True, True)

If you are using the same handler for multiple controls, you could use
something like:

Me.SelectNextControl(DirectCast(sender, Control), True, True,
True, True)

Hope this helps
Jay


Thanks, I'll look check this out.



" Just Me" <gr****@a-znet.com> wrote in message
news:uw**************@TK2MSFTNGP11.phx.gbl...
Below is the result of the wizard conversion from VB6.

Looking at the Help doc I can find an example that uses Chaw()

If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
e.Handled = True
End If

But isn't there a more DotNet approach to comparing a character to see if
it's a CR.?

How would you do this?

Thanks

Private Sub ComboBoxFindStr_KeyPress(ByVal ...snip

Dim lKeyAscii As Short = Asc(e.KeyChar)

'make CR work like TAB

If lKeyAscii = 13 Then

System.Windows.Forms.SendKeys.Send("{TAB}")

lKeyAscii = 0

End If

If lKeyAscii = 0 Then

e.Handled = True

End If

End Sub


Nov 21 '05 #21

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: SB | last post by:
This while loop keeps repeating even when a correct character is entered.... cout<<endl<<"What day would you like to schedule the appointment?"<<endl; cout<<endl<<"Enter 'M' for Monday, 'T' for...
2
by: Pradyut | last post by:
I have made a program in which I'm trying to return the string in which the character is found. I'm doing this through pointers. I'm not able to figure out the correct way: printf("%s",...
29
by: interpim | last post by:
Just a quick exercise from my C programming book, that I can't figure out why it isn't working properly. It kinda works but im getting wierd output. It is supposed to remove the vowels from text. ...
88
by: William Krick | last post by:
I'm currently evaluating two implementations of a case insensitive string comparison function to replace the non-ANSI stricmp(). Both of the implementations below seem to work fine but I'm...
0
by: none | last post by:
Hello This question is more Interop related but since that newsgroup seems to be abandoned, I thought I give this newsgroup a try. I have an OCX that exposes several classes and I need to...
0
by: Just Me | last post by:
Below is the result of the wizard conversion from VB6. Looking at the Help doc I can find an example that uses Chaw() If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then e.Handled = True End...
2
by: ddd | last post by:
I am trying to build a diff tool that allows me to compare two HTML files. I am looking for resources on how to achive this. The main problem is that I do not want to simply highlight the line of...
3
by: perlrocks | last post by:
hello everyone can anyone suggest me the perl code for comparing two sequences by each character wise and to print the characters which are not matched .... can anyone give me a hint on this
5
by: =?Utf-8?B?UElFQkFMRA==?= | last post by:
Not really a C#-specific comment, more general .net observations. 1) A while back I found the need to determine whether or not a particular StringComparer was case-insensitive. The best way I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.