Results 1 to 7 of 7

Thread: one letter

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2007
    Posts
    34

    one letter

    if txtNaam.text = "O?:" & lstGekozenOpties.List(i) Then

    the ? must represent one! letter. Must I use ? or * or something else ?

  2. #2
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: one letter

    wait what letter do you want ? to represent there is 26 :P

  3. #3
    Fanatic Member Dnereb's Avatar
    Join Date
    Aug 2005
    Location
    Netherlands
    Posts
    863

    Re: one letter

    You need to use Like instead of Equals to(=)

    if txtNaam.text Like "O?:" & lstGekozenOpties.List(i) Then
    why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
    for every question you ask provide an answer on another thread.

  4. #4
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: one letter

    You don't NEED TO the only problem here is that he hasn't stated everything

  5. #5
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: one letter

    Quote Originally Posted by Hell-Lord
    wait what letter do you want ? to represent there is 26 :P
    Any of them.. he wants "?" to represent a wild card!

  6. #6
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: one letter

    Here is one way (I have had a few...):
    VB Code:
    1. Option Explicit
    2.  
    3. Const ALPHABET As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    4.  
    5. Private Sub Command1_Click()
    6.     If Left$(txtNaam.Text, 1) = "O" And InStr(1, ALPHABET, Mid$(txtNaam.Text, 2, 1), vbTextCompare) And Mid$(txtNaam.Text, 3, 1) = ":" Then
    7.         If Mid$(txtNaam.Text, 4, Len(txtNaam.Text) - 4) = lstGekozenOpties.List(i) Then
    8.             'Do something
    9.         End If
    10.     End If
    11. End Sub

  7. #7
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: one letter

    Hmmm overkill - try this:

    Use Like() to pattern match.

    VB Code:
    1. If UCase(txtNaan.Text) Like ("O[ABCDEFGHIJKLMNOPQRSTUVWXYZ]:" & UCase(lstGekozenOpties.List(i))) Then
    2.         'Do stuff
    3.     End If

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