bro sakto na si softtouch, i think sa VB6 naa nay KEYPRESS dira. so pwede ra evey KEYPRESS echeck nimu if ang key isNumeric. If so, continue, if it is not a numeric you can send a BEEP and do nothing else.
bro sakto na si softtouch, i think sa VB6 naa nay KEYPRESS dira. so pwede ra evey KEYPRESS echeck nimu if ang key isNumeric. If so, continue, if it is not a numeric you can send a BEEP and do nothing else.
solve your problem using Microsoft Masked Edit Control, this provides an ability to control, restrict,and provide preformatted inputs to the system and fully helps your users as it gives some clues/guide on how to input such values.
using regular expressions, builtin functions or event (keys) might do, but IMHO it does not provide effectiveness in your program, in a professional manner. And you have to catch some invalid inputs and might call more functions on the end. To think, that some inputs may led to system crash or bogus executions.
There is a .NET version and a COM Object version.
GoodLuck!
Bitaw effective kau na na control. easy to use sd. dli lang kau ni ipagamit sa students usahay. hehehe
teachers doesn't know? or never written on their student plan ? hehehe... We had a discussion on this bloody control, and we ended up debating "late/early bindings". Anyway, to cut the story, We use it only in some of our applications where the given inputs are directly process in our database (via stored procedure). The error was resolve along W/ .NET redistribution.
wala paman ko ka ku-an ana .net
mas sayon na sa vb6 or lisod?
softouch is right..
there are a lot of approaches in solving it and let me share you the simpliest and a better way in accepting only numbers in keypress event in vb6..
txtID = control name
Private Sub txtID_KeyPress(KeyAscii As Integer)
If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii =Then KeyAscii = 0
End Sub
note: every keys have it's ascii equivalent. like 0(number) = 48 (ascii)..so the code means if the input is not ascii from 48-57 or 0-9(in number itself) it returns 0 in ascii or no keyboard input...try to know the ascii equivalents of the keyborad inputs for you to know how to handle them..and by the way the cool smiley above is number '8' and it means a backspace key..heheh
hope it helps..happy coding..
dude... better better better better there are a lot of better codes because it is freely available on internet, where dumb coders will just have to copy/paste... code that exist 5 to 10 years ago.
there's a lot of bug using this ascii you know? like what happened in KeyAscii from VB.
BUG: KeyAscii Behavior Different with DBCombo Control
in the first place, why would someone code it like that? especially if you will consider future enhancement, on which you will going to include alphanumeric characters?
I wonder why UTF-8 came out to replace ASCII, ISO 8859 and EUC at all types of levels, perhaps one of it was due to backward compatability... one of my friends tried to compile my source and later came back to me and said... "you handed me a puzzle of unmatched data type variable." without considering that we have to deal with unicode values from COM Object, and some IDE/GUI generate unicode strings, thus, code referring to If KeyAscii fails!!
thanks guy
@markcuering - i just said "better" coz it is not the best approach(we all know that)..f u wanted to share ur knwldge dnt make it complicated..a simple solution for a simple problm is d best way to learn..d TS just asked for a simple solution and i thnk d sample s good enough..he'll learn later what are the thngs that he must know..i got your point and you are right..the more knowldge u have d more problems u must handle..in reality, the more knwldge u gain for programming the more it becomes complicated..have a good day to all..
Agree, my post doesn't mean anything personalit is often use anyway (ASCII) like in game development, console, etc...
Similar Threads |
|