Consulting

Results 1 to 8 of 8

Thread: Searching for values in an in-string list.

  1. #1

    Searching for values in an in-string list.

    Hi team,

    I have a list box with about 900 entries entries in it.

    For specific items (about 200 ~ 300 of them) I need a warning window to pop up.

    I've got the test code done.

    What I'm after is a better, tidier way to list the values I'm searching for as the search criteria THING_xx, as I've said will be 200 or 300 items.

    The search text won't be sequential per my demo text (just to make life harder).

    If push comes to shove, I might have to do a swag of these things :-(

    Select Case True
    Case (InStr(THING_List(), "(THING_01)") > 0), (InStr(THING_List(), "(THING_02)") > 0) , (InStr(THING_List(), "(THING_03)") > 0)
    UserForm8.Label1123.Visible = True
    UserForm8.Label1114.Visible = True
    MsgBox "message box text.", , "MSGBOX TITLE"
    End Select

    As always your help is appreciated


    Regards
    Kes

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    What, exactly, does THING_List() contain?
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Hi Paul,

    With THING_List
    .portion_01 = "(5912)" 'This is the identifier line I'll be searching for...
    .portion_02 = "1"
    .portion_03 = "stuff"
    End With
    Addbits THING_List

    Sorry if I'm vague, but it's quite propriety to the industry I'm in...


    Regards
    Kes

  4. #4
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by kestrel1306 View Post
    Sorry if I'm vague, but it's quite propriety to the industry I'm in...
    Indeed it is - I'm none the wiser as to how that relates to what you're trying to do. That said, maybe something along the lines of the following will get you started:
    Dim lVal As Long
    Select Case True
      If InStr(THING_List(), "(THING_") > 0 Then
        lVal = CLng(Split(Split(THING_List(), "(THING_")(1), ")")(0))
        Select Case lVal
          Case 1 - 100
            UserForm8.Label1123.Visible = True
            UserForm8.Label1114.Visible = True
            MsgBox "message box text.", , "MSGBOX TITLE"
          Case Else
        End Select
      End If
      Case Else
    End Select
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  5. #5
    Hi Paul,

    Sorry for being so mysterious...

    .portion_01 is essentially a 4 or 5 digit serial number. Either starting with either an alpha or a numeric.

    It is totally non-sequential so would need to list the specific item somewhere (I think?)

    I was wondering if it would be easier if I made a .portion_04 = "yes" or "no" and searching for that somehow...

    I'm totally an amateur at this (as you've no doubt guessed)


    Regards
    Kes

  6. #6
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Sorry, but there just isn't enough meaningful content & context in what you've posted for me to make sense of what's going on.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  7. #7
    Can you PM me at all? (unsure of the rules for that on here)


    Kes

  8. #8
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,335
    Location
    I have a list box with about 900 entries entries in it.

    For specific items (about 200 ~ 300 of them) I need a warning window to pop up.

    How about just an simple example.

    I have a list box with 5 items.

    Tom
    Dick
    Harry
    Moe
    Curley

    I need a warning to pop up when "WHAT"
    Greg

    Visit my website: http://gregmaxey.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •