Jump to content

trying to get a text from a text box be displayed into a message box

fdfdfdf
Go to solution Solved by minibois,
Just now, fdfdfdf said:

well they kinda did and didn't. my teacher went and just told us stuff to do for hours and that point my brain switched off. so do I not have it as a null?

 

string fruit = TextBoxNameHere.Text;

MessageBox.Show("you are eating " + fruit);

 

hi I am trying to get text that would be collected into a text box. so if a user entered cheese into it could then be referenced in the message box. i am having a real hard time trying to get this to work and so far my attempts have just resulted in blank spaces where the text should be. can anyone help me i have been stuck at this for hours trying to figure out what i am meant to do 

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, fdfdfdf said:

hi I am trying to get text that would be collected into a text box. so if a user entered cheese into it could then be referenced in the message box. i am having a real hard time trying to get this to work and so far my attempts have just resulted in blank spaces where the text should be. can anyone help me i have been stuck at this for hours trying to figure out what i am meant to do 

What language? What code do you have?

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, minibois said:

What language? What code do you have?

this is c# as per the tag. the code is bellow 

 

string fruit = "";

 MessageBox.Show("you are eating " + fruit);

 

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, fdfdfdf said:

this is c# as per the tag. the code is bellow 

 


string fruit = "";

 MessageBox.Show("you are eating " + fruit);

 

you set fruit as an empty string and display it. the text being empty shouldn't really be a surprise.

are you sure your school literature doesn't go over how to get text from a textbox?

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, fdfdfdf said:

this is c# as per the tag. the code is bellow 

 


string fruit = "";

 MessageBox.Show("you are eating " + fruit);

 

I did have a text box in there but I got annoyed and deleted it. I am trying to get an input from user which would then be repeated in message box

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, minibois said:

you set fruit as an empty string and display it. the text being empty shouldn't really be a surprise.

are you sure your school literature doesn't go over how to get text from a textbox?

well they kinda did and didn't. my teacher went and just told us stuff to do for hours and that point my brain switched off. so do I not have it as a null?

 

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, fdfdfdf said:

well they kinda did and didn't. my teacher went and just told us stuff to do for hours and that point my brain switched off. so do I not have it as a null?

 

string fruit = TextBoxNameHere.Text;

MessageBox.Show("you are eating " + fruit);

 

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, minibois said:

string fruit = TextBoxNameHere.Text;

MessageBox.Show("you are eating " + fruit);

 

thanks for helping me out man

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, fdfdfdf said:

thanks for helping me out man

Please do try to figure this sort of stuff out yourself next time. Not that I don't like providing a solution, but more that debugging your code and figuring things out is 80% of your skillset as a programmer.

Next time think of how to do this sort of stuff in a logical way:

- I need to get user input

- This user input is in a textbox

That should spark in your mind you have to do something with that textbox. From there on, you could type TextBoxNameHere (or whatever the name is), type a dot after it and Visual Studio will help you out and show everything you may need to type there as suggestions (sometimes the one you want will be highlighted at the top). If you just scroll through this list, you will see the different options (properties and function) with a little explanation behind it.

 

Or you could have Googled: "visual studio forms get text from textbox"

and found this: https://stackoverflow.com/questions/10696941/c-sharp-get-string-from-textbox

which gave the same explanation.

 

I am not trying to bug you, but just try to give you some input on how you could solve these sorts of issues. Solving issues and effectively looking for solution are highly needed skills for a programmer. Try to test yourself with that sort of stuff.

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, minibois said:

Please do try to figure this sort of stuff out yourself next time. Not that I don't like providing a solution, but more that debugging your code and figuring things out is 80% of your skillset as a programmer.

Next time think of how to do this sort of stuff in a logical way:

- I need to get user input

- This user input is in a textbox

That should spark in your mind you have to do something with that textbox. From there on, you could type TextBoxNameHere (or whatever the name is), type a dot after it and Visual Studio will help you out and show everything you may need to type there as suggestions (sometimes the one you want will be highlighted at the top). If you just scroll through this list, you will see the different options (properties and function) with a little explanation behind it.

 

Or you could have Googled: "visual studio forms get text from textbox"

and found this: https://stackoverflow.com/questions/10696941/c-sharp-get-string-from-textbox

which gave the same explanation.

 

I am not trying to bug you, but just try to give you some input on how you could solve these sorts of issues. Solving issues and effectively looking for solution are highly needed skills for a programmer. Try to test yourself with that sort of stuff.

see the issue is for me is that in the rest of my assignment I have got working. my deadline is coming up on Friday actually and I have probably spent 3x as long as everyone else as I have done some funky things with my code like adding if statements that aren't needed or make it harder to understand. I really do apricate the help because I feel so far behind because I am v dyslexic and have a sh*t teacher who just talks and doesn't let us code until he is finished. when you ask him a question he says go look on stackoverflow. I have been banned from stackoverflow because my questions where to bad but the community on here is way nicer and less toxic. 

Link to comment
Share on other sites

Link to post
Share on other sites

8 minutes ago, fdfdfdf said:

see the issue is for me is that in the rest of my assignment I have got working. my deadline is coming up on Friday actually and I have probably spent 3x as long as everyone else as I have done some funky things with my code like adding if statements that aren't needed or make it harder to understand. I really do apricate the help because I feel so far behind because I am v dyslexic and have a sh*t teacher who just talks and doesn't let us code until he is finished. when you ask him a question he says go look on stackoverflow. I have been banned from stackoverflow because my questions where to bad but the community on here is way nicer and less toxic. 

Do let me know if you're stuck on anything else.

Good luck in your studies!

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, minibois said:

Do let me know if you're stuck on anything else.

Good luck in your studies!

thanks you man. 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×