473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

One form accesses controls on a different form - good practice?

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?

Nov 20 '05 #1
1 1753
Cor
Trebor,
I am from before the time of structured programming but a Dijkstra follower
(One of the first inventors of structured programming)

One of the main reasons for structured programming was to keep your program
readable.
(Small parts that could be handled. For that OO programming has no
difference in my opinion).
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

We often say in this newsgroup that one of the advantage's of VB.net is,
that it has the possibility to do it in your own way.
But I don't think this is good practise I never saw it in that way been
described by someone.
(Sometimes people ask how to do it in this way, but they never get that
answer).

Some thoughts

Cor
Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
4
by: darrel | last post by:
I have a contact form that a person submits to the server. In ASP, you'd make a page, post the form to another page, which would grab the values and do somethign with them. in ASP.NET, it...
2
by: Sky Sigal | last post by:
Hello: I'm currently messing around, and need as much feedback/help as I can get, trying to find the most economical/graceful way to build usercontrols that rely on styling to look any good... ...
17
by: Barret Bonden | last post by:
As an old programmer just now looking at VB.net I have a question: How does one simply open one form from another ? I don't mean how does one create a new instance of that form , but rather how...
7
by: Boni | last post by:
Dear all, if I do myform.close() is it disposed or not? is it correct do following? myForm.close() Info=SomeControlOntheForm.text This seems to work. But am not sure that it is waterproof....
17
by: Timothy.Rybak | last post by:
Hello all, This is my first attempt at an application, so kid gloves are appreciated. I need to make a very simple form that only has a few elements. One is TraceCode - a text field that is...
9
by: netasp | last post by:
hi all, how can I populate one aspx form when page is loading based on page ID? for example: loading page A (to search for VB code) would display labels and texboxes, dropdown lists all related...
5
by: Miro | last post by:
I will try my best to ask this question correctly. I think in the end the code will make more sence of what I am trying to accomplish. I am just not sure of what to search for on the net. I...
8
by: Justin Rich | last post by:
So another simple question from me :) as im working away ive made a button that does a series of wonderful things.. and as it goes along it suppose to update a label to let the user know what...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.