code:
Sub updateData(ByVal qici As String, ByVal r As Integer)
'请求数据
Set h = CreateObject("Microsoft.XMLHTTP")
h.Open "GET", "http://www.17500.cn/3d/3Ddetail.php?i=" & qici, False '文件网址
h.send
If h.Status = 200 Then
s = h.ResponseText '写入取得的内容
Dim regex
Set regex = CreateObject("VBScript.RegExp")
With regex
.Global = True
.Pattern = "(\d{3})" '得到号码
Set matchs = .Execute(s)
End With
'MsgBox matchs(0).Value
If matchs.Count > 0 Then '防止空集
s = Mid(matchs(0).Value, 4, 3)
Cells(r, 2) = Left(s, 1)
Cells(r, 3) = Mid(s, 2, 1)
Cells(r, 4) = Right(s, 1)
End If
Set regex = Nothing
Set matchs = Nothing
Set h = Nothing
End If
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Application.Calculation = xlManual
Dim s As String, last As Integer, col As Integer, r As Integer
col = Target.Column: r = Target.Row
last = Range("A" & Rows.Count).End(xlUp).Row
If col = 1 And r >= 1003 Then '更新开奖号
qici = Cells(r, 1).Text
Call updateData(qici, r)
End If
Application.Calculation = xlAutomatic
End Sub