简体   繁体   中英

excel-vba codes

can anyone explain me the below codes...

Public Sub delay(seconds As Long)
            Dim endTime As Date
            endTime = DateAdd("s", seconds, Now())
            Do While Now() < endTime
                DoEvents
            Loop
        End Sub

    Function GetText2(ByVal strText, ByVal strStartTag, ByVal strEndTag)
        Dim intStart, intEnd
        intStart = CLng(InStr(1, strText, strStartTag, vbTextCompare))

        If intStart Then
            intStart = CLng(intStart + Len(strStartTag))
            intEnd = InStr(intStart + 1, strText, strEndTag, vbTextCompare)
            If intEnd <> 0 Then
             GetText2 = Mid(strText, intStart, intEnd - intStart)
           Else
              GetText2 = ""
            End If
        Else
            GetText2 = ""
        End If
    End Function

Abhi, it looks to me like the GetText2 function accepts three strings, searches for the second and third strings in the first string, and returns the text between the second and third strings. So for example:

GetText2("The quick brown fox jumps over the lazy dog","quick","fox")

should return the string:

"quick brown fox"

The delay sub simply causes the program to pause for the specified number of seconds.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM