CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2009
    Posts
    20

    If Statement not working (Properties.Settings)

    Have a quick question:

    I have some Properites.Settings set up. One setting is passwordhint.

    On one form I have a textbox (textbox1) and a label (label3)

    The user will enter the password hint in the textbox1 and the label3 will show the Properties.Settings.pass

    I do know in VB.NET it is
    Code:
    If Textbox1.Text = My.Settings.passhin Then
    Label3.Text = My.Settings.passhin
    End If
    However, I am very new to C# and this is kinda confusing.......

    I have right now:

    Code:
    {
                If(textBox1.Text = Properties.Settings.Default.passhin);
                {
                    label3.Text = Properties.Settings.Default.passhin;
    
                }
    but it wont work....... Can someone help me with the syntax needed??

    Thanks in advanced.

    daveofgv

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: If Statement not working (Properties.Settings)

    Code:
    if (Textbox1.Text == My.Settings.passhin) {
    	Label3.Text = My.Settings.passhin;
    }
    http://www.developerfusion.com/tools.../vb-to-csharp/
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Aug 2009
    Posts
    20

    Re: If Statement not working (Properties.Settings)

    Erors say:

    The name 'Textbox1' does not exist in the current context
    The name 'My' does not exist in the current context
    The name 'Label3' does not exist in the current context
    The name 'My' does not exist in the current context


    Am I suppose to delcare the above? If so, how?

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: If Statement not working (Properties.Settings)

    Sound slike you are trying to reference these outside the class they are in. In which case you would get the same errors in VB.Net
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Aug 2009
    Posts
    20

    Re: If Statement not working (Properties.Settings)

    Thanks. I will look into it and let you know.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured