CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2011

    [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:
    if (Names.Text = "Airplane 1")
    Names.Text = "Alpha Airplane"
    if (Names.Text = "Airplane 2")
    Names.Text = "Beta Airplane"
    But VS is throwing an error of Cannot implicitly convert type 'string' to 'bool' How can I do this?

  2. #2
    Join Date
    May 2011

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.