how to convert a textbox value to string value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • umarhayat
    New Member
    • Dec 2014
    • 1

    how to convert a textbox value to string value

    i create two forms add a password in first form throgh user input and second form will open i want that password will automatically be added to second form. first form is ok working according to my expactations but problem that it does not enter pssword in second form i reference that textbox that is
    stdfrm std=new std();
    std.a=txtpwd;
    it displays an error that
    cannot implicitly convert type system.windows. forms.textbox to string
    please need help
  • Joseph Martell
    Recognized Expert New Member
    • Jan 2010
    • 198

    #2
    Umarhayat
    It is important to remember that all of the controls and forms that you are using are still classes with properties and methods. The TextBox control is a specific class. A TextBox has a lot of associated properties and methods. One of those properties is Text. I think the following code will work:

    Code:
    std.a = txtpwd.Text
    If further help is needed please post a larger example of your code and please use code tags. It makes it easier to read and for others to reference (line numbers and all that).

    Comment

    Working...