943,723 Members | Top Members by Rank

Ad:
Jul 3rd, 2009
0

Probably a silly question.. but im new to delphi :)

Expand Post »
hi,

i havent been programming in delphi long so sorry if im being stupid with this question.

my application basically has a trackbar which alters the value of a label caption.

and 2 text boxes.

that value of the 1st text box is the Caption of the label * the text in the 2nd text box.

what i would like to know is, how do i make this value automatically update each time the slider is moved and the label caption changes.

appreciate the help
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
revski is offline Offline
28 posts
since Jul 2009
Jul 3rd, 2009
0

Re: Probably a silly question.. but im new to delphi :)

Remember Delphi is strongly typed so you need to type cast your calculations as below:

Pascal and Delphi Syntax (Toggle Plain Text)
  1. Edit1.Text := StrToInt (Label1.Caption) * StrToInt(Edit2.Text);

You should probably put this in the appropriate event on the Slider control, OnChange should be a good one.
Last edited by andrevanzuydam; Jul 3rd, 2009 at 10:03 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
andrevanzuydam is offline Offline
7 posts
since Jun 2009
Jul 3rd, 2009
0

Re: Probably a silly question.. but im new to delphi :)

sorry i didnt explain the situation very well in the first place i missed a serious point off.

the initial value of the calculations is made by a button on the form, this is because they are standard set values by the factory for that machine, but the value would alter depending on the position of the trackbar.

so what im asking is as the value of the trackbar goes up or down, it needs to update the value of the text box automatically.

im unsure how to do this because there is an original calculation performed by a button click.

but the value of the label will change each time the trackbar is moved.

i have only the calculation in the OnClick event of the button, in the OnChange event of the trackbar it increases or decreases the value of the label.

Sorry for not explaining this clearer the first time.
Reputation Points: 10
Solved Threads: 0
Light Poster
revski is offline Offline
28 posts
since Jul 2009
Jul 4th, 2009
0

Re: Probably a silly question.. but im new to delphi :)

A label doesn't have a OnChange event so you may want to replace the label with a TEdit (you can adjust the properties to make it look like a label) and then make the OnChange event on that do the same calculation as the button - if that is what you need it to be achieved. Another thought is that you should have a function or procedure to do the calculations which automatically update all the correct TEdits and labels when an event is fired. It would be good if you could paste some code, I am still not clear on what you need to achieve.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
andrevanzuydam is offline Offline
7 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: Multithread+BDE+Oracle database Error
Next Thread in Pascal and Delphi Forum Timeline: Please help me with calculation in delphi.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC