• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

How do you display the data you entered in a Textbox to a MessageBox in C#?

I've declared the variable "singleEntry" below as a TextBox. Not sure I've I should have declared the variable type as String. None the less, I want to display the data you enter in a Textbox to a MessageBox in C#?
Most grateful,
WD
TextBox singleEntry = textBoxSingle.Text;

Open in new window

0
wally_davis
Asked:
wally_davis
  • 2
1 Solution
 
YourReferenceCommented:
System.Windows.Forms.MessageBox.Show(singleEntry);
0
 
Jaime OlivaresCommented:
it should be like:

System.Windows.Forms.MessageBox.Show(yourTextBox.Text);
0
 
Jaime OlivaresCommented:
notice TextBox is a control class, not a string, if you want to use the string inside the control, you have to use the .Text property
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now