繁体   English   中英

Excel-VBA代码

[英]excel-vba 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,在我看来, GetText2函数接受三个字符串,在第一个字符串中搜索第二个和第三个字符串,然后返回第二个和第三个字符串之间的文本。 因此,例如:

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

应该返回字符串:

"quick brown fox"

delay子仅使程序暂停指定的秒数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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