Help with error

Discussion in 'Code Snippets and Tutorials' started by Billy, Apr 9, 2007.

  1. Billy

    Billy Level IV

    Joined:
    Feb 21, 2007
    Messages:
    1,856
    Likes Received:
    39
    i keep on getting an error on this
    Code (Text):
    1. newmsg = FindString(strhtml, "class='mainmenu'>", "new message")
    but i cant seem to figure out what the problem is.
     
  2. expon

    expon Administrator
    Staff Member

    Joined:
    Oct 30, 2006
    Messages:
    1,393
    Likes Received:
    56
    Location:
    UK
    what is the error?
     
  3. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    use this function NOT MINE
    Code (Text):
    1. Public Function FindString(TextToSearch As String, StartText As String, EndText As String, Optional StartPos As Long = 1)
    2. Dim sText As Long, eText As Long
    3.  
    4. sText = InStr(StartPos, TextToSearch, StartText, vbTextCompare) + Len(StartText)
    5. eText = InStr(sText, TextToSearch, EndText, vbTextCompare)
    6. If sText >= Len(StartText) And eText > sText Then
    7.     FindString = Mid$(TextToSearch, sText, eText - sText)
    8. Else
    9.     FindString = ""
    10. End If
    11. End Function
     
  4. Billy

    Billy Level IV

    Joined:
    Feb 21, 2007
    Messages:
    1,856
    Likes Received:
    39
    for findstring could i do this?
    Code (Text):
    1. event = FindString(strhtml, "</b><p><p>", "<p><form")
    2. if event= "" then
    3. log.additem ("nothing happened")
    4. else: log.AddItem (event)
    5.  
    i am trying to display nothing happened if the string doesnt appear, and if it does, i want it to display what the strings value is, would i use that code?