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

Ryan AlfordRank #1,411 · 1.2K reputationPosted Mar 26, 2008, 2:59 PM EDT
Loren Black5 reputationPosted Mar 26, 2008, 3:34 PM EDT
If pressing '1' is giving you that idea then think of it as clicking the '1' button in the GUI app.
Sergio Fonseca54 reputationPosted Mar 26, 2008, 4:45 PM EDT
Loren Black5 reputationPosted Mar 26, 2008, 5:46 PM EDT
I apologize for wasting everyone's time. :)