4
我仍然試圖從網頁中獲取一些數據,我得到了一個解決方案,如何「grep」HTML文本,但現在我試圖從文本中分離出一些部分是在一個字符串中。Instr中的溢出錯誤
我想取出變量A和變量B之間的部分,並使用下面的代碼。
我總是得到一個Runtime error 6 Overflow
,有人有一個想法爲什麼以及如何解決這個問題?
Sub Button1_Click()
Const HTTPREQUEST_PROXYSETTING_PROXY = 2
Dim oRequest As Object, pagetext, third As String, first, second As Integer
Set oRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
oRequest.Open "GET", "http://www.vodafone.de/privat/handys-tablets-tarife/smartphone-tarife.html"
oRequest.Send
pagetext = oRequest.ResponseText
first = InStr(pagetext, "window.phones")
second = InStr(first + 1, pagetext, "window.propositions")
third = Mid(pagetext, first + 1, second - first - 1)
MsgBox (third)
End Sub
似乎你的'第三個'變量沒有被標註。如果你將'Option Explicit'作爲模塊的第一行粘貼,你可以幫助你避免很多運行時錯誤。 – 2014-10-31 10:54:05
這不符合你的想法。 Dim oRequest As Object,pagetext,as As String,first,second As Integer'。 PageText和第一個被聲明爲變體。 – RubberDuck 2014-11-01 01:27:48