Textbox Update

Textbox Update

Anonymous
Not applicable
245 Views
3 Replies
Message 1 of 4

Textbox Update

Anonymous
Not applicable
Is there a way to right a userform code that will update a textbox when
a value changes in another textbox i.e. I divide a distance between 2
points by a number I call quantity which obviously is the number of a
particular item I want. The second box is the width of the item done by
the above calculation. I disable the box from editing but I would like
the text to recalculate when I change the quantity number.
0 Likes
246 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
with a form with three textboxes, named "length", "qty" and "result".

Private Sub qty_Change()
result.Value = length.Value / qty.value
End Sub

Assuming you had numeric value in length textbox,
that would continually change the value in result whenever numeric value is
entered in qty.
If you don't use a keypress event to limit entry to numeric you'd get type
mismatch.
Alternately you could, by using the exit event, update the value in result
after the qty textbox value was changed and then focus shifts to another
control.

Private Sub qty_Exit()
result.Value = length.Value / qty.value
End Sub

In any case you have to ensure it's numeric data in order to get meaningful
result. so obviously you need some error control going on...
If you never want to edit the text but just want to see the result you could
also use a label and use it's caption property to display your result.
good luck and have fun
Mark

Travis Williams wrote in message
news:3C882F64.40800@stargate.net...
> Is there a way to right a userform code that will update a textbox when
> a value changes in another textbox i.e. I divide a distance between 2
> points by a number I call quantity which obviously is the number of a
> particular item I want. The second box is the width of the item done by
> the above calculation. I disable the box from editing but I would like
> the text to recalculate when I change the quantity number.
>
0 Likes
Message 3 of 4

Anonymous
Not applicable
Hi Mark,
Not that it makes a difference, but I tend to use the ".text" property.
The 2 are basically redundant and if I had to guess, I would say the
".value" property was just carried over by inheritance from another
class since .value shows up in other controls whereas .text is unique to
the textbox control.
-Josh

MP wrote:

> with a form with three textboxes, named "length", "qty" and "result".
>
> Private Sub qty_Change()
> result.Value = length.Value / qty.value
> End Sub
>
> Assuming you had numeric value in length textbox,
> that would continually change the value in result whenever numeric value is
> entered in qty.
> If you don't use a keypress event to limit entry to numeric you'd get type
> mismatch.
> Alternately you could, by using the exit event, update the value in result
> after the qty textbox value was changed and then focus shifts to another
> control.
>
> Private Sub qty_Exit()
> result.Value = length.Value / qty.value
> End Sub
>
> In any case you have to ensure it's numeric data in order to get meaningful
> result. so obviously you need some error control going on...
> If you never want to edit the text but just want to see the result you could
> also use a label and use it's caption property to display your result.
> good luck and have fun
> Mark
>
> Travis Williams wrote in message
> news:3C882F64.40800@stargate.net...
>
>>Is there a way to right a userform code that will update a textbox when
>>a value changes in another textbox i.e. I divide a distance between 2
>>points by a number I call quantity which obviously is the number of a
>>particular item I want. The second box is the width of the item done by
>>the above calculation. I disable the box from editing but I would like
>>the text to recalculate when I change the quantity number.
>>
>>
>
>
>
>
0 Likes
Message 4 of 4

Anonymous
Not applicable
Thanks for the tip. I was always wondering why there were two properties
for the same thing.


"Minkwitz Design" wrote in message
news:3C88DFFB.7040505@ameritech.net...
> Hi Mark,
> Not that it makes a difference, but I tend to use the ".text" property.
>
0 Likes