Results 1 to 4 of 4

Thread: String Question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2008
    Posts
    207

    String Question

    How would I do something like this?

    Code:
    If Left(Me.lstUsers.Text, 1) != "@", "+" Then
    Like how would I make it say "If the first letter on the selected user doesn't equal @ or + Then..."

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: String Question

    You are practically there...
    Code:
    If Left(Me.lstUsers.Text, 1) <> "@" Or Left(Me.lstUsers.Text, 1) <> "+" Then
    
    Else
    
    End If
    You can also use Select Case:
    Code:
    Select Case Left(Me.lstUsers.Text, 1)
        Case "@", "+"
            'do something
        Case Else
            'do something else
    End Select

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: String Question

    If Left(Me.lstUsers.Text, 1) <> "@" Or Left(Me.lstUsers.Text, 1) <> "+" Then
    The above statement will always evaluate to True.

    Use AND instead of OR when checking for inequality.

    If Left(Me.lstUsers.Text, 1) <> "@" AND Left(Me.lstUsers.Text, 1) <> "+" Then

    Another way to achieve the same results.

    If Not(Left(Me.lstUsers.Text, 1) = "@" Or Left(Me.lstUsers.Text, 1) = "+") Then

  4. #4

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