[RESOLVED] Convert string to Bool
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: [RESOLVED] Convert string to Bool

Hybrid View

  1. #1
    Join Date
    May 2011
    Posts
    44

    [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:
    Code:
    if (Names.Text = "Airplane 1")
    Names.Text = "Alpha Airplane"
    else
    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
    Posts
    44

    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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center