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

Member Avatar for andre.vanzuydam

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

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.

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.

Member Avatar for andre.vanzuydam

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.