程式碼如下:
Sub ComBoxInit()
With ComboBox2
.List = Array("日線", "還原日線")
.Text = "清單"
End With
End Sub
Private Sub ComboBox2_Change()
End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub CommandButton1_Click()
Dim web
Dim URL As String, code As String
Dim i As Long, j As Integer, d As Integer
If TextBox1.Text = "" Then Exit Sub
code = TextBox1.Text
URL = "http://jsstock.wls.com.tw/Z/ZC/ZCW/CZKC1.djbcd?c=402&b=" & IIf(ComboBox2.Text = "還原日線", "A", _
IIf(ComboBox2.Text = "名目週線", "W", "M")) & "&a=" & code
Set web = CreateObject("Microsoft.XMLHTTP")
web.Open "get", URL, False
web.send
ReDim arr(1 To Int((Len(web.responseText) - Len(Replace(web.responseText, ",", ""))) / _
(Len(web.responseText) - Len(Replace(web.responseText, " ", "")) + 1)) + 1, 1 To 6)
For i = 1 To 6
For j = 1 To Int((Len(web.responseText) - Len(Replace(web.responseText, ",", ""))) / _
(Len(web.responseText) - Len(Replace(web.responseText, " ", "")) + 1)) + 1
arr(j, i) = Application.Index(Split(Application.Index(Split(web.responseText, " "), 1, i), ","), 1, j)
Next j
Next i