Learning C# need some help.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was wondering how I would go about outputting text into a textbox1 as well
as getting data entered into it by the user?

Example:

I ask: Input cash amount:
Then below that
they put in $24.54 hit enter

more or less how to make the textbox act like a console application...
 
AngryWhiteBoy said:
I was wondering how I would go about outputting text into a textbox1 as well
as getting data entered into it by the user?

Example:

I ask: Input cash amount:
Then below that
they put in $24.54 hit enter

more or less how to make the textbox act like a console application...

You can set the Text property just as easily as you can read it.
 
I assume this is a windows form application...

You ask "Input cash amount" by placing a label on the form.
You place "Textbox1" on the form.
You place an OK button on the form.
On the form, you find the AcceptButton property and set it to the name of
the OK button.
Put code into the Click event of the OK button to read the Textbox1.Text
property... that will give you the data the user entered.

This is called event-driven programming.

--- Nick
 
AngryWhiteBoy said:
I was wondering how I would go about outputting text into a textbox1 as well
as getting data entered into it by the user?

Example:

I ask: Input cash amount:
Then below that
they put in $24.54 hit enter

more or less how to make the textbox act like a console application...

setting:
textbox1.Text = "$24.54"

retrieving:
Dim myValue As String = textbox1.Text

Mythran
 
Assuming youre using C#, you can use many visual basic.net examples

Make a new windows form

make 2 text boxes from the tools thing on the left side

make 1 button also

Now view the code and just after the CLASS definition, make your variable
str a public variable like this:

partial class Form1 : Form

{

public string str;

This way your program can operate on the same variable, giving it a larger
SCOPE


double click on the first textbox
inside the brackets, type
str = textBox1.Text;

now double click on the button, inside those brackets, type

textBox2.Text = str;

Id suggest trying to operate on button clicks instead of using the
enter/return button for now, because you have to have the focus on your
textbox for the return button to act as a click for that box
 
Back
Top