Lost Password?

Go Back   CodeCall Programming Forum > Software Development > Pascal/Delphi

Vote on your favorite hash algorithm here!

Pascal/Delphi Forum for discussing Borland Delphi and Pascal coding techniques, tips and tricks.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-29-2007, 01:58 AM
Nefrit's Avatar   
Nefrit Nefrit is offline
Newbie
 
Join Date: Nov 2007
Posts: 12
Credits: 0
Rep Power: 0
Nefrit is on a distinguished road
Question Delphi help

I decided to test my Delphi knowlege today by making myself a calculator. Took me a while, bu I figured most of it out. It all works well, except for one problem.

If, for example, you press 9 + 2 + 5, what I'd love it to do is to clear the screen when the next button after the plus sign is pressed, entering only the value of that button, clearing the values that were there before it. Can anyone help? I know that it's probably some sort of On..... thing.

Anyone here insane enough to know any Delphi anyway?
__________________
Gartengeräte Solarenergie
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 11-29-2007, 11:16 AM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 2,535
Last Blog:
wxWidgets is NOT code ...
Credits: 919
Rep Power: 28
WingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the rough
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-25-2008, 02:15 PM
poots poots is offline
Newbie
 
Join Date: Feb 2008
Location: London
Posts: 3
Credits: 0
Rep Power: 0
poots is on a distinguished road
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT -5. The time now is 09:13 AM.

Contest Stats

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

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 83%

Ads