If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > Like function problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-28-11, 13:54
pfm200586 pfm200586 is offline
Registered User
 
Join Date: Oct 2011
Posts: 6
Like function problem

hello everyone,


I am trying to check each letter of a word if that word doesn't contain (AEIOUY) then I have to append (-way) to the end of the word. Now I have this if statement and it doesn't work:


If OriginalWord.ToUpper Like "*[!AEIOUY]*" Then
Label1.Text = OriginalWord & "-way"
End If
any suggestion to make it work. I need to append a (-way) to the end of a word that doesn't have (AEIOUY)


thank you guys

Regards
Reply With Quote
  #2 (permalink)  
Old 10-30-11, 16:56
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Is this in classic Visual Basic? Or VB.Net or are you trying to do this in SQL? Assuming you are using VB.Net have a look at these examples
Code:
        Console.WriteLine(("DFGHJKL" Like "[AEIOUY]")) 'False
        Console.WriteLine(("DFGAHJKL" Like "*[AEIOUY]*")) 'True
        Console.WriteLine(("EFGHJKL" Like "[AEIOUY]*")) 'True
        Console.WriteLine(("FGHJKLI" Like "*[AEIOUY]")) 'True
        Console.WriteLine(("OFGHJKL" Like "*[AEIOUY]*")) 'True
        Console.WriteLine(("FGHJKLU" Like "*[AEIOUY]*")) 'True
        Console.WriteLine(("DFGHJKL" Like "![AEIOUY]")) 'False
        Console.WriteLine(("DAJKL" Like "![AEIOUY]")) 'False
        Console.WriteLine(("DFGAEKL" Like "![AEIOUY]"))  'False
        Console.WriteLine(("DFARETIWOVUBYJKL" Like "![AEIOUY]")) 'False
The way the like works with the ! operator and a character list is non-intuative. I would actually recommend doing a check in this manner... which I haven't tested but I think should work
Code:
If (!(OriginalWord.ToUpper Like "*[AEIOUY]*")) Then
    Label1.Text = OriginalWord & "-way"
End If
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On