- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¥»©«³Ì«á¥Ñ GBKEE ©ó 2016-1-9 15:36 ½s¿è
¦^´_ 2# stillfish00
¦^´_ 3# joey0415
ºî¦X2¦ì,¨Ï¥Îªí³æ§e²{,¥i¿ï¾Ü¦a°Ï,¸ê®Æ®æ¦¡,®É¶¡. ¶×¤J©Ònªº®ð¶H¸ê®Æ.
·s¼W UserForm(ªí³æ) ¤¤¥[¤JComboBox1, ComboBox2, ComboBox3 ,CommandButton1- Option Explicit
- Dim xObject()
- Private Sub UserForm_Initialize()
- xObject = Array(ComboBox1, ComboBox2, ComboBox3)
- Æ[´ú¬d¸ß_³]©w
- Com
- ComboBox1.Value = ComboBox1.List(0)
- ComboBox2.Value = ComboBox2.List(0)
- End Sub
- Private Sub ComboBox1_Change() '´ú¡@¡@¯¸
- Com
- End Sub
- Private Sub ComboBox2_Change() '¸ê®Æ®æ¦¡
- Dim i As Double
- With ComboBox3
- .Clear
- Select Case ComboBox2.ListIndex
- Case 0 '
- For i = Date - 1 To DateAdd("Q", -1, Date) Step -1
- .AddItem
- .List(.ListCount - 1) = Format(i, "YYYY-MM-DD")
- Next
- Case 1
- i = Date
- Do
- .AddItem
- .List(.ListCount - 1) = Format(i, "YYYY-MM")
- i = DateAdd("M", -1, i)
- Loop Until Year(i) < Year(Date) - 1
- Case 2
- For i = Year(Date) To Year(Date) - 1 Step -1
- .AddItem
- .List(.ListCount - 1) = i
- Next
- End Select
- If ComboBox2.ListIndex > -1 Then .Value = .List(0)
- End With
- Com
- End Sub
- Private Sub ComboBox3_Change() '®É¡@¡@¶¡
- Com
- End Sub
- Private Sub Com() '
- Dim E As Variant
- With CommandButton1
- .Enabled = True
- For Each E In xObject
- If E.ListIndex = -1 Then .Enabled = False '«ö¯Ã(Æ[´ú¸ê®Æ¬d¸ß):¤£¥i¥Î
- Next
- End With
- End Sub
- Private Sub CommandButton1_Click() '«ö¯Ã(Æ[´ú¸ê®Æ¬d¸ß)
- Dim surl As String, QT As QueryTable
- 'http://e-service.cwb.gov.tw/HistoryDataQuery/YearDataController.do?command=viewMain&station=467410&datepicker=2016
- 'http://e-service.cwb.gov.tw/HistoryDataQuery/MonthDataController.do?"
- 'http://e-service.cwb.gov.tw/HistoryDataQuery/DayDataController.do?
- surl = "URL; http://e-service.cwb.gov.tw/HistoryDataQuery/"
- Select Case ComboBox2.ListIndex
- Case 0
- surl = surl & "DayDataController.do?"
- Case 1
- surl = surl & "MonthDataController.do?"
- Case 2
- surl = surl & "YearDataController.do?"
- End Select
- surl = surl & "command=viewMain&station=" & ComboBox1.List(ComboBox1.ListIndex, 1)
- surl = surl & "&datepicker=" & ComboBox3
- With ActiveSheet
- .Cells.Delete
- Set QT = .QueryTables.Add(Connection:=surl, Destination:=.Range("$A$1"))
- With QT
- .WebFormatting = xlWebFormattingNone
- .Refresh BackgroundQuery:=False
- .Delete
- End With
- End With
- Set QT = Nothing
- End Sub
- Private Sub Æ[´ú¬d¸ß_³]©w()
- Dim i As Double, E As Object, op As Object
- Dim oXmlhttp As Object, oHtmldoc As Object, Url As String
- Set oXmlhttp = CreateObject("msxml2.xmlhttp")
- Set oHtmldoc = CreateObject("htmlfile")
- Url = "http://e-service.cwb.gov.tw/HistoryDataQuery/QueryDataController.do?command=viewMain" '
- With oXmlhttp
- .Open "Get", Url, False
- .Send
- oHtmldoc.write .responseText
- End With
- With oHtmldoc
- Set E = .all.tags("SELECT")(0)
- Set op = .all.tags("option")
- End With
- For i = 0 To op.Length - 1
- If i <= E.Length - 1 Then
- With ComboBox1
- .AddItem
- .List(.ListCount - 1, 0) = op(i).innertext '´ú¯¸:¦WºÙ
- .List(.ListCount - 1, 1) = op(i).Value '´ú¯¸:¼ÆÈ
- End With
- Else
- With ComboBox2
- .AddItem
- .List(.ListCount - 1, 0) = op(i).innertext '¸ê®Æ®æ¦¡:¦WºÙ
- End With
- End If
- Next
- End Sub
½Æ»s¥N½X |
|