Numerical Keypad entry interdict?

PrivateSub Display_KeyPress(ByVal senderAsObject,ByVal eAs System.Windows.Forms.KeyPressEventArgs)Handles Display.KeyPress

Dim allowedCharsAsString ="0123456789."

If allowedChars.IndexOf(e.KeyChar) = -1Then e.Handled =True

If Display.Text.IndexOf(".") >= 0And e.KeyChar ="."Then e.Handled =True

EndSub

This code below makes it work.

PrivateSub Form1_KeyPress(ByVal senderAsObject,ByVal eAs System.Windows.Forms.KeyPressEventArgs)HandlesMe.KeyPress

If e.KeyChar >= ChrW(48)And e.KeyChar <= ChrW(57)Or e.KeyChar = ChrW(8)Or e.KeyChar = ChrW(46)Or e.KeyChar = ChrW(45)Then

Display.Text = e.KeyChar.ToString()

EndIf

EndSub

PM 11:50 Sunday ET

Well, it works.

PROBLEM: THE KEY ENTRY HAS TO BE SLOWN DOWN, OTHERWISE GIVES DOUBLE, QUATRUPLE ENTRIES.

If Display.Text ="0"Then Display.Text =""

Display.Text = Display.Text + e.KeyChar.ToString

A = Convert.ToDouble(Display.Text)

EndIf

MsgBox("hello")

Here the entry between numbers is slown down with "hello". Is that not crazy?

MS help me out here, please.

[4267 byte] By [CesarFrancisco] at [2008-1-9]
# 1

Cesar,

That sounds like a something that might occur when you double up on code perhaps?

I would recommend that since the keypress functionality is the same, just varied by which key you press, you should write a function to handle that scenario, and then call another function to perform work.

The function I alluded to above should be written to perform whatever work needs to be performed when a button is pressed or clicked.

It will then make it easy to set a breakpoint inside your work performing code, when you can trace back through the stack and see what events are being raised, then you are likely to be able to discover what the problem is.

I hope this helps you,

Martin Platt.

MartinPlatt at 2007-10-3 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

You were right.

CesarFrancisco at 2007-10-3 > top of Msdn Tech,Visual Basic,Visual Basic General...