Interdependent controls :TextBox

  • Thread starter Thread starter =?ISO-8859-1?Q?Paul-Andr=E9_C=F4t=E9?=
  • Start date Start date
?

=?ISO-8859-1?Q?Paul-Andr=E9_C=F4t=E9?=

Hi,
I've been playing with VBx and VB.NET for a while
now but ...

Let say in VB.Net, I've never understood how or
which event I should use when I update one of two
interdependent textboxes.

Let say I've 2 textbox : TB1 and TB2.

TB2 depends sometimes of TB1.

TB1 may be modified by the user.
If so TB2 must take TB1 value, if boolean B1 is
true, else TB2 is unchanged.

TB1 may be set within VB code, then TB2 mustn't
change.

So here's my questions :

1) Where could I find informations on how to
manage interdependent textbox ?
2) Which event would be thrown if it's the user
who have changed TB1?
3) Which event would be thrown if the changing
was done within VB ?
4) How can I make the difference in VB ?
5) Is there a way to turn off events, so in code I
could say "Don't bother with "changed"
events for the next few instructions?

Thanks for any helps,
Paul
 
Paul,

You ask something that is mostly a cruel and where you can use the event
"value changed from both textboxes". However be aware not to create an
endless cycle.

Something as using two textboxes where
textbox2 = 10 times textbox1

When you let the user change both textboxes, will need that you do
something in both events (rougly typed just as idea)

In the event of textbox1
\\\
if CDbl(textbox2.text) <> CDbl(textbox1.text)*10 then
textbox2.text = (Cdbl(textbox1.text) * 10).ToString
'this throws the value change event of textbox2
end if
///
In the event of textbox2
\\\
if CDbl(textbox1.text) <> CDbl(textbox2.text)/10 then
textbox1.text = (Cdbl(textbox2.text) / 10).ToString
'this throws the value change event of textbox1
end if
///

I hope this helps?

Cor
 
Back
Top