4 Replies - 1152 Views - Last Post: 20 October 2011 - 11:57 AM Rate Topic: -----

#1 menukadevinda  Icon User is offline

  • D.I.C Regular

Reputation: -7
  • View blog
  • Posts: 470
  • Joined: 14-April 11

how to chekc keyaski in vb.net

Posted 20 October 2011 - 11:39 AM

hi all,

I have done vb6 but not vb.net
in the keypress event we can check aski value in vb6
I can check whether key is number of character

but I dnt know how to do this in vb.net

help me
thx

txtBalance_keypress(keyAscii as integer)
select case keyascii
case is > 57
Beep

end select


this is ok in vb6
not in vb.net

help
Private Sub txtRegNo_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtRegNo.KeyPress
        Select Case sender
            Case Is > 57
                Beep()
                sender = 0
            Case 27 To 47
                Beep()
                sender = 0
        End Select


this is the code i tried

This post has been edited by macosxnerd101: 20 October 2011 - 11:41 AM
Reason for edit:: Use code tags!!!


Is This A Good Question/Topic? 0
  • +

Replies To: how to chekc keyaski in vb.net

#2 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1461
  • View blog
  • Posts: 3,289
  • Joined: 30-January 11

Re: how to chekc keyaski in vb.net

Posted 20 October 2011 - 11:44 AM

You need to get the KeyChar out of the KeyPressEventArgs object that is passed into the function.

...
If IsNumeric(e.KeyChar)Then
    // do something
Else
    // Key is not numeric, do something else
End If



Or something to that effect.
Was This Post Helpful? 0
  • +
  • -

#3 menukadevinda  Icon User is offline

  • D.I.C Regular

Reputation: -7
  • View blog
  • Posts: 470
  • Joined: 14-April 11

Re: how to chekc keyaski in vb.net

Posted 20 October 2011 - 11:51 AM

Select Case Microsoft.VisualBasic.Asc(e.KeyChar)

            Case Is > 57
                Beep()
                e.Handled = False
            Case 27 To 47
                Beep()
                e.Handled = False
        End Select



I want to stop typing charaters
stil this doesnt work
Was This Post Helpful? 0
  • +
  • -

#4 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1461
  • View blog
  • Posts: 3,289
  • Joined: 30-January 11

Re: how to chekc keyaski in vb.net

Posted 20 October 2011 - 11:55 AM

Did you even read my earlier post?

You might want to take a look at this link. You should be able to come to a solution from their answers.
Was This Post Helpful? 0
  • +
  • -

#5 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1822
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: how to chekc keyaski in vb.net

Posted 20 October 2011 - 11:57 AM

If you need only numbers to be entered then at these links:
Functions to limit textBox entries
Create number only textBox tutorial
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1