Results 1 to 8 of 8

Thread: [RESOLVED] if statment

  1. #1

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Resolved [RESOLVED] if statment

    What's wrong with this statment,

    d Code:
    1. If IDcountry.Text = "United States of America" Then
    2.             IDState.Enabled = True
    3.  
    4.             If IDcountry.Text <> "United States of America" Then
    5.                 IDState.Enabled = False
    6.             End If
    7.         End If

    IDState is always enabled :S

    thx

  2. #2
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: if statment

    is it enabled when it loads? if so what kind of control is IDCountry?

    Pretty sure you were using dropdownlists but I may be mistaken... if you are try IDCountry.SelectedText

  3. #3
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: if statment

    Your if block is a bit of a paradox; the code that disabled the IDState field will execute when the IDcountry.Text field is both equal to "United States of America" and not equal to "United States of America".

    Refactoring/correcting:
    Code:
    If IDcountry.Text = "United States of America" Then
       ''' Enable field
    Else
       ''' Disable field
    End If
    
    ''' Or...
    IDState.Enabled = (IDcountry.Text = "United States of America")
    I would suggest that you debug & step through the code next time

  4. #4
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: if statment

    you also might want to show us what event it supposed to be firing this code....

  5. #5

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Re: if statment

    Yes they are dropdownlist.
    well, it didn't work with .text , so i used
    vb Code:
    1. IDState.Enabled = (IDcountry.SelectedValue = "US")
    and it works. But i don't know why it didn't work with the .text.

  6. #6
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: if statment

    did you checked with IDcountry.Text.Trim
    __________________
    Rate the posts that helped you

  7. #7

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Re: if statment

    works with trim
    thx

  8. #8
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: [RESOLVED] if statment

    Glad it worked but best way is to go ahead with IDcountry.SelectedValue if needed add IDcountry.SelectedValue.Trim.
    __________________
    Rate the posts that helped you

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