I have a simple form with a textbox.
When the user hits '1' the textbox should display '1'.
But let's look inside the program:
Normally, I could do something like: setText("1");
But since I'm trying to incorporate OOP principles, I should be doing something more like: ghostClass.setText("1");
setText() basically does this -> theTextBox.Text = textToSet;
Yes, without OOP, that'd work. But with OOP, the ghostClass shouldn't
even know theTextBox exists right? So it can't do this ->
theTextBox.Text = textToSet; <- because this -> The name
'theTextBox' does not exist in the current context. <- would happen.
I was thinking that instead of -> setText("1") <- I should be
using somethign clsoer to -> theTextBox.Text =
ghostClass.setText("1"); <- but when I look at that I feel it should
just say -> theTextBox.Text = "1"; <- and that I have unnecssary
complicated the code--I mean why would I sent the text to set only to
have it returned? -_-
I could eleborate on the issue even more by introducing another method
-> ghostClass.clearTextBox(); As before I can't use ->
theTextBox.Text = string.Empty <- because of the existence issue.
Please help.
Loading
Loren BlackPosted Mar 26, 2008, 9:46 PM
I apologize for wasting everyone's time. :)
Sergio FonsecaPosted Mar 26, 2008, 8:45 PM
Loren BlackPosted Mar 26, 2008, 7:34 PM
If pressing '1' is giving you that idea then think of it as clicking the '1' button in the GUI app.
Ryan AlfordPosted Mar 26, 2008, 6:59 PM