Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
excelvba代码_Excel_Vba - Fatal编程技术网

excelvba代码

excelvba代码,excel,vba,Excel,Vba,谁能给我解释一下下面的代码 Public Sub delay(seconds As Long) Dim endTime As Date endTime = DateAdd("s", seconds, Now()) Do While Now() < endTime DoEvents Loop End Sub Function GetText

谁能给我解释一下下面的代码

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

在我看来,GetText2函数接受三个字符串,在第一个字符串中搜索第二个和第三个字符串,并返回第二个和第三个字符串之间的文本。例如:

GetText2("The quick brown fox jumps over the lazy dog","quick","fox")
应返回字符串:

"quick brown fox"

延迟子命令只会导致程序暂停指定的秒数。

读取VBA帮助时,代码中没有任何内容无法理解。你到底想知道什么?看看@Remou也看看这个@belisarius是的。我已经标记了。@Abhi:欢迎来到StackOverflow。我已经回答了你的问题。同时,请在这里查看我们的常见问题解答:并熟悉该网站以及主题问题中被认为是好的方面。谢谢