December 22nd, 2012, 01:18 PM
[RESOLVED] Convert string to Bool
I have a windows form where I have a textbox that the user selects text from and then based on that text selection code will execute. I now need to set up a if statement that will if the user chooses "Airplane 1" from the textbox the code will change the name to "Alpha Airplane" or if the user selects "Airplane 2" from the textbox it changes the name to "Beta Airplane" I tried this code:
But VS is throwing an error of Cannot implicitly convert type 'string' to 'bool' How can I do this?
if (Names.Text = "Airplane 1")
Names.Text = "Alpha Airplane"
if (Names.Text = "Airplane 2")
Names.Text = "Beta Airplane"
December 22nd, 2012, 02:48 PM
Re: Convert string to Bool
Another young learning mistake made by myself....instead of it being "=" it should have been "=="
Maybe this can help someone who comes across this post later on.
Click Here to Expand Forum to Full Width