[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

lowercase lettere and upper case lettere vb.net

lowercase lettere and upper case lettere vb.net

madushka930

10/9/2011 2:13:00 PM




iwant to find the pressed key is lower or upper how can i do this..
please help me... i tried this .. but i have got an same result at
every time..

Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress

If e.KeyChar.IsLower(ChrW(Keys.A)) Then
MsgBox("a")
Else
MsgBox("A")
End If

END SUB

Peter Duniho

10/9/2011 9:03:00 PM

On 10/9/11 6:13 AM, madushka930 wrote:
>
> iwant to find the pressed key is lower or upper how can i do this..
> please help me... i tried this .. but i have got an same result at
> every time..

System.Char.IsLower() is a static method, requiring that you pass in the
character you want to know about. The code you posted always passes the
same character to the method (the character generated by converting the
non-character value of Keys.A to a character), and so will always have
the same result.

Try instead:

If System.Char.IsLower(e.KeyChar) Then
MsgBox("a")
Else
MsgBox("A")
End If

Note that had you tried to write that code in C#, the compiler would
have refused to let you call the static method as an instance method.
VB.NET works great for a lot of things, but if you're going to use it,
it's worth remembering that the language is a lot more flexible in
certain ways and can allow you to write code that isn't literally doing
what it might look to the human reader that it's doing.

Pete

Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
lowercase lettere and upper case lettere vb.net

Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te

Il servizio è completamente GRATUITO!