|
||||||
| Pascal/Delphi Forum for discussing Borland Delphi and Pascal coding techniques, tips and tricks. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
| Sponsored Links |
|
|
|
|||||
|
Delphi is the language I use at work.
You haven't given us much of anything to work with right now. Not knowing anything about the form you're using, or the logic used, I can't offer much.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||
|
the problem you'll be having is that any event fired from within a tedit box will blow up if you try to clear it from inside that event.
This may not be the best solution, but it's the best that comes to mind. You need a form with a tedit and a tmemo on it. The Tmemo contents will be what you need to parse to do the maths. unit Calcstarter; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Edit1: TEdit; Memo1: TMemo; procedure FormCreate(Sender: TObject); procedure FormKeyPress(Sender: TObject; var Key: Char); private Operators : Set of Char; Numerals : set of Char; Specials : set of Char; public end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin KeyPreview :=true; //this ensures the form gets first look at what's typed edit1.readonly := true;//to stop users actively entering in it Operators := ['/','+','-','*']; Numerals := ['0'..'9']; Specials := ['.' , ',' , '=']; end; procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char); begin if Key in Operators then begin if length(edit1.text) <> 0 then begin memo1.Lines.Add(Key ); memo1.lines.Add(edit1.Text ); edit1.Text := ''; end; end; if ((key in Numerals) or (key in Specials)) then begin Edit1.Text := edit1.Text + key; end; end; end. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Delphi TMediaplayer | marshmap | Pascal/Delphi | 2 | 07-31-2008 06:46 AM |
| Class question in Delphi | tosh5457 | Pascal/Delphi | 4 | 06-11-2007 01:46 PM |
| Delphi: 2 apps sharing the same DLL instance? | ArgusMike | Pascal/Delphi | 0 | 04-12-2007 02:58 PM |
| Small job - Database extraction - Delphi 7 of compliant | paul. | Request Services (Paid) | 4 | 04-11-2007 11:41 AM |
| What is Delphi? | dirkfirst | Pascal/Delphi | 6 | 07-08-2006 12:11 AM |
| Xav | ........ | 1357.94 |
| MeTh0Dz|Reb0rn | ........ | 1083.85 |
| WingedPanther | ........ | 919.18 |
| morefood2001 | ........ | 909.18 |
| marwex89 | ........ | 906.86 |
| John | ........ | 902.37 |
| Brandon W | ........ | 789.89 |
| chili5 | ........ | 312.39 |
| Steve.L | ........ | 264.99 |
| dcs | ........ | 240.34 |
Goal: 100,000 Posts
Complete: 83%