Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

newbie question,help needed ASAP


  • Please log in to reply
2 replies to this topic

#1 CalypsoDJ

CalypsoDJ

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 22 December 2008 - 10:43 AM

hello everyone! i have a problem with adding a new code, i have no idea where to put code for clearing result (going from 0). for this particular task code that should be put somewhere is:

lbRez.Caption:='0'

and the task is this:

procedure TForm1.btIzracunajClick(Sender: TObject);
var A,B:Integer;
    begin
        If edA.Text='' then
          ShowMessage('No entry')
        else If edA.Text='0' then
          ShowMessage('First number must not be zero')
        else
           A:=StrToInt(edA.Text);
        
        If edB.Text='' then
          ShowMessage('No entry')
        else If edB.Text='0' then
          ShowMessage('Second number must not be zero')
        else
          B:=StrToInt(edB.Text);
     
      lbRez.Caption:=FloatToStr(-B/A);
end;

end.

Edited by WingedPanther, 22 December 2008 - 11:56 AM.
add code tags (the # button)

  • 0

#2 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 22 December 2008 - 11:59 AM

I would initialize A and B to 0, then check if A equals 0.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#3 ooisootuck

ooisootuck

    CC Regular

  • Just Joined
  • PipPipPip
  • 29 posts

Posted 03 January 2009 - 04:58 AM

For variable initialization, you can either do it in FormCreate or FormShow.

Thanks
  • 0




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download