Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How do i read in what is inputted into a text box in Visual Studio? Do i need to

ID: 3911397 • Letter: H

Question

How do i read in what is inputted into a text box in Visual Studio? Do i need to call a stream? I have the below code, but i keep getting an error. I have a Form1.cs & ProgramTest.cs. I want to read what is written into the enter.txt and convert it to a string that can be read. But i am having trouble trying to have both cs files communicate with each other.

When i did a console application i could use the following bolded code, but this doesnt work with a Visual Studio form. What is the equivalent code to read in text in a form??

pattern = (Console.ReadLine()).ToUpper(); //read user input

Form 1.cs

DISPLAY display;

public Form1()
{
InitializeComponent();
display = new DISPLAY();

//i want what is inputted through the enter1.text to be read through the inputPattern in program.cs

display.InputPattern();

mydisplay1.Text = display.returnScreenValue();
  
}

Program.cs

public String inputValue { get; set; }

public String InputPattern()
{
inputValue = pattern;

}

Explanation / Answer

You can get the user's input by using the text property like textbox name.Text.

Pass the entered text to the below call method

display = new DISPLAY(textbox name.Text);

When the above method calls the constructor then initialize the input value variable first.

For example inputValue=passed text // this will assign the user text to the variable that is must.

then you call

display.InputPattern();

mydisplay1.Text = display.returnScreenValue();

It will work.

NOte:

The text from the textbox will always be a string.

communicating between cs files can be done only be passing the content in object creation or through parameterized constructor and initialization.

For further concerns please comment, I will please to help you

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote