Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to assign an EditMask of 000.00 to a TDBEdit Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
28-Aug-02
Category
Database-VCL
Language
Delphi 2.x
Views
132
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas 

I have a TDBEdit component linked to a string field. I have an assigned EditMask = 
'000.00' to capture a $ amount (I cannot make the field numeric). When the user 
enters 0.00, the data is being stored as '0 .00' in the table. What is the correct 
EditMask for such an entry? Or do I have to get the data from another property to 
store in the table?

Answer:

An EditMask can be awkward. I tend toward tidying up with custom formatting.

1   procedure TForm1.MaskEditEnter(Sender: TObject);
2   begin
3     if Sender is TMaskEdit then
4       TMaskEdit(Sender).EditMask := '!999.99;1; ';
5   end;
6   
7   procedure TForm1.MaskEditExit(Sender: TObject);
8   begin
9     if Sender is TMaskEdit then
10      TMaskEdit(Sender).Text := MyMoneyFormat(TMaskEdit(Sender).Text);
11  end;
12  
13  function MyMoneyFormat(S: string): string;
14  var
15    X: Integer;
16    R: string;
17  begin
18    R := '0';
19    for X := 1 to Length(S) do
20      if S[X] <> ' ' then
21        R := R + S[X];
22    Result := Format('%0.002f', [StrToFloat(R)]);
23  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC