Results 1 to 3 of 3

Thread: Finding A String, Within a string.. replace & action

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482

    Exclamation

    Hey, i have a SET LENGTH string that i need to find.

    But the string that i have to find can be anything.
    the string is like:
    &#########&

    it will ALWAYS be 11 letters long.and always have a & at the beginning and end of the string. the ### will be replaced by letters and numbers

    I have to SEARCH for the 11-Letter string, (in a string).
    there will be no spaces after or before the & on each side. so it would be like

    Blah&#########&blah

    And once it finds it, I have to do an ACTION using that String (it will be put into a variable) and then it will erase the 11-character string from the Searched string.

    and it will keep searching for the string until the end of the string.

    -----
    I guess you would SEARCH the string for any &.. then check if that along with the next 10 characters equals a correct string.. then do an action

    Thanks... not sure how to do this myself

    [Edited by progeix on 12-03-2000 at 09:31 PM]

  2. #2

  3. #3
    Guest

    Arrow

    i guess if it were me i'de use a loop thru the string,
    i'll attempt to give an example but im really tired haha

    'data = your string that u wanna search thru

    'variable to hold found chunk
    Dim findings As String

    'variable for the loop
    Dim i As Integer

    'loop once for every char in string
    For i = 1 to Len(Data)
    'if the '&' is found and 10 chars after that is '&' then
    If Mid(Data,i,1) = "&" And Mid(Data,i + 10,1) = "&" Then
    'this is your chunk
    findings = Mid(Data,i,11)

    'do your action with it, whatever u need to do here
    '*************************************************

    'and i thought u said you wanted to delete that
    'chunk after u were done with it? If so then:
    Data = Left(Data,i-1) & Right(Data,Len(Data)-(i+10))

    End If
    Next

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