megatronixs
Registered User.
- Local time
 - Today, 15:40
 
- Joined
 - Aug 17, 2012
 
- Messages
 - 719
 
Hi all,
I need to fix a part of a function that takes a piece of text from html page.
The current function will only take the first string of numbers that come after a 0 href=javascript:LinkCase(0,123456,'Daltonia Limited',0,654321)
so I will get only 123456.
I'm trying to get now the company name too , but I get empty string.
This is the part of the code that gets me 123456:
	
	
	
		
from this html body: href=javascript:LinkCase(0,123456,'Daltonia Limited',0,654321)
How to get "Daltonia Limited" ?
This is the function used:
	
	
	
		
Greetings.
 I need to fix a part of a function that takes a piece of text from html page.
The current function will only take the first string of numbers that come after a 0 href=javascript:LinkCase(0,123456,'Daltonia Limited',0,654321)
so I will get only 123456.
I'm trying to get now the company name too , but I get empty string.
This is the part of the code that gets me 123456:
		Code:
	
	
	CaseNumber = GetPartSTR(ie.document.body.innerHTML, "javascript:LinkCase(0,", ",'") 'find the case number in the body of the web page
	How to get "Daltonia Limited" ?
This is the function used:
		Code:
	
	
	Function GetPartSTR(ByRef FullSTR As String, ByVal FromSTR As String, ByVal ToSTR As String, Optional ByVal StartText As String = vbNullString, Optional StartNum As Long = 1) As String
    Dim vSTART      As Long
    Dim vEND        As Long
    Dim StartChar   As Long
    Dim Effect      As String
    Dim regex       As New RegExp
    Dim previous    As Long
    
    On Error GoTo What
    If IsNumeric(StartText) Then
      StartNum = StartText
      StartText = vbNullString
    End If
    If Len(StartText) < 2 Then
        StartChar = StartNum
    Else
        StartChar = InStr(StartNum, FullSTR, StartText, vbTextCompare)
    End If
    vSTART = InStr(StartChar, FullSTR, FromSTR, vbTextCompare)
    vEND = InStr(vSTART + Len(FromSTR), FullSTR, ToSTR, vbTextCompare)
    If vSTART > 0 And vEND > 0 Then
        If ToSTR = vbNullString Then
            Effect = Mid(FullSTR, CLng(vSTART + Len(FromSTR)))
        Else
            Effect = Mid(FullSTR, CLng(vSTART + Len(FromSTR)), vEND - vSTART - Len(FromSTR))
        End If
    Else
        Effect = vbNullString
    End If
    Do
      previous = Len(Effect)
      While Right(Effect, 2) = vbNewLine
        Effect = Left(Effect, Len(Effect) - 2)
      Wend
      While Left(Effect, 2) = vbNewLine
        Effect = Right(Effect, Len(Effect) - 2)
      Wend
      While Right(Effect, 1) = " "
        Effect = Left(Effect, Len(Effect) - 1)
      Wend
      While Left(Effect, 1) = " "
        Effect = Right(Effect, Len(Effect) - 1)
      Wend
    Loop While previous > Len(Effect)
    
    GetPartSTR = Effect
    Exit Function
What:
    GetPartSTR = vbNullString
End Function