Solved

Dynamically enter numeric values in Maskedit control

Posted on 1998-11-22
3
584 Views
Last Modified: 2012-06-21
Hi,
I am using a Maskedit box that can accept only numeric values. The Maskedit box has got two decimal places. At runtime when i enter values , firstly the maskedit box does not right align the numbers, cuz there is not such align property for it. Secondly if the numbers are entered one by one, they remain the same on the screen and do not get formatted. Like for eg, if the mask is "___.__" and i enter "2_2.__" the lostfocus shows the same "2_2.__" even if hideselection is false.

Is there a way first to dynamically start entering numbers from the right most side of the maskedit box and second how do i backspace the numbers i.e if i delete any numerals. I have written function to convert "2_2.__" to "022.00" in the lostfocus. Any Help?
0
Comment
Question by:ravicha
3 Comments
 
LVL 5

Expert Comment

by:scrapdog
ID: 1446165
Maskedit boxes are usually not very versatile...you could try to simulate your own using a regular edit box...do your validation in the change event, and update the position of the insertion point accordingly.
0
 
LVL 1

Expert Comment

by:wford
ID: 1446166
I agree with scrapdog..try setting up a normal text box..I personaly use the keypress event..since then you can stop invalid input. Don't for get to leave at least backspace, return and delete keycodes enabled.
0
 
LVL 3

Accepted Solution

by:
myqlG earned 100 total points
ID: 1446167
everyone is right so far.
use a text box and on lostfocus use the format command to make
it all work
You can also enter only text by using something like this in
the keypress event:
If IsNumeric(Chr(KeyAscii)) = False And KeyAscii <> vbKeyBack And KeyAscii <> vbKeyDelete And KeyAscii <> vbKeyReturn Then KeyAscii = 0
If KeyAscii = vbKeyReturn Then
KeyAscii = 0
Call keybd_event(9, 0, 0, 0): Call keybd_event(9, 0, 2, 0)
End If
(I cut and pasted this so dont ask about keybd_event)
I use that instead of sendkeys because of a known sendkeys/numlock error.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now