Results 1 to 5 of 5

Thread: InStr, Need Clarification

  1. #1

    Thread Starter
    Member cramtheman's Avatar
    Join Date
    Dec 2000
    Posts
    43

    Question

    Can someone please clarify about the InStr command, how it works, an example and will it work with arrays.

    Thanks
    cram
    [email protected]
    _ _ _ _ _ _ _ _ _ _ _ _ _ _
    Things to Ponder

    |Man who stands on toilet,
    Is high On pot|
    |Baseball Wrong,
    Man with four balls cannot walk|

  2. #2
    Guest
    It searches for a string within another string.
    Code:
    Str1 = "This is a string"
    Str2 = "is"
    If InStr(1, Str1, Str2) > 0 Then MsgBox "Str2 is found in Str1"
    What do you mean by work with Array's? If you loop through each element in the array then yes, it will work.

  3. #3

    Thread Starter
    Member cramtheman's Avatar
    Join Date
    Dec 2000
    Posts
    43
    what I meant was instead of using str1 in your example, can you use an array?
    cram
    [email protected]
    _ _ _ _ _ _ _ _ _ _ _ _ _ _
    Things to Ponder

    |Man who stands on toilet,
    Is high On pot|
    |Baseball Wrong,
    Man with four balls cannot walk|

  4. #4
    Addicted Member
    Join Date
    Aug 2000
    Posts
    208
    yes..
    like:
    Code:
    Dim Array1(1) As String
    
    Array1(0) = "This is a String"
    Array1(1) = "is"
    
    If InStr(1, Array1(0), Array1(1)) > 0 Then 
       MsgBox Array1(1) & " is found in " & Array1(0)
    Else
       MsgBox Array1(1) & " is not found in " & Array1(0)
    End If

  5. #5
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Code:
    Dim x&
    Dim Arr(1) As String
    Arr(0) = "Hello"
    Arr(1) = "I'm Jop"
    For x = 0 to Ubound(Arr)
       if Instr(1, Arr(0), "Jop") then MsgBox "Array " & x & "contains Jop!"
    next x
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

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