T
trebor
I'm learning dotNet, although I first learned programming back in the
days when structured programming was all the rage. In both my books and
courses, I've seen something like this:
Public Class FormA
Inherits System.Windows.Forms.Form
Private Sub Button_Click(ByVal etc., etc.) Handles btnCalculate.Click
FormB.Textbox.Text = "some updated value"
End Sub
Is this good programming practice? Somehow, it just feels wrong to
access a form's controls FROM A DIFFERENT form.
Isn't this no different from A accessing B's local variables? I know
compilers will let you to do it, but I learned that was not good
programming practice because (among other things) a ripple effect could
introduce subtle and difficult bugs.
And if this IS good programming practice, what's the rationale behind
it? What changed over the past 15 years?
days when structured programming was all the rage. In both my books and
courses, I've seen something like this:
Public Class FormA
Inherits System.Windows.Forms.Form
Private Sub Button_Click(ByVal etc., etc.) Handles btnCalculate.Click
FormB.Textbox.Text = "some updated value"
End Sub
Is this good programming practice? Somehow, it just feels wrong to
access a form's controls FROM A DIFFERENT form.
Isn't this no different from A accessing B's local variables? I know
compilers will let you to do it, but I learned that was not good
programming practice because (among other things) a ripple effect could
introduce subtle and difficult bugs.
And if this IS good programming practice, what's the rationale behind
it? What changed over the past 15 years?