Results 1 to 2 of 2

Thread: How to make OR statements.

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2011
    Posts
    38

    How to make OR statements.

    How do I make an OR Statement.

    Im trying to do this

    Code:
    name3 = [name2].EndsWith("," Or "." Or "?" Or "!" Or ";" Or ":")

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to make OR statements.

    The Or goes between multiple EndsWith calls, not within one, e.g.
    vb.net Code:
    1. If str.EndsWith(substr1) OrElse str.EndsWith(substr2) Then
    Notice the use of OrElse rather than Or. Likewise you generally use AndAlso rather than And.

    Having said that, given that you are looking for substrings of the same length in each case, you could structure your code a little differently, e.g.
    vb.net Code:
    1. If {substr1, substr2}.Contains(str.Substring(str.Length - substringLength)) Then
    The list you call Contains on can be any length and be constructed any way you like.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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