ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

¥Îexcel¤Wºô¬d­µ¼Ð ¤S±¾¤F

¥»©«³Ì«á¥Ñ HSIEN6001 ©ó 2012-7-12 20:31 ½s¿è

Sorry ~~§¹¾ãªº¬q¸¨¬O³o¼Ë~~
<input type='hidden' name='filename' value='t108sb27_20120712_17145551.csv'>
<table class='noBorder' align='center' width='100%'><tr><td align='left'>

VBA.Split ¯S§O¬Ý¤£À´
http://msdn.microsoft.com/zh-tw/library/system.string.split.aspx

InStr¨ç数¥iªð¦^¤@个¦r²Å¦ê¦b¥t¤@个¦r²Å¦ê¤¤­º¦¸¥X现ªº¦ì¸m¡C
http://www.w3school.com.cn/vbscript/func_instr.asp
InStr([start,]string1,string2[,compare])

½Ð°Ý...
InStr(VBA.Split(.responseText, "<table class='noBorder")(1)
¤¤ªº(1)¬O¬Æ»ò·N«ä?!

TOP

¦^´_ 2# GBKEE
¶¶±a½Ð±Ð¡G ¨Ï¥Î VBA.Split »P ¨ç¼Æ¤§ Split ¹ê°ÈÀ³¥Î¤W¨ì©³¦³¦ó®t²§¡H

TOP

¦^´_ 11# HSIEN6001
  1. Option Explicit
  2. Sub Ex() 'Split¦b¦r¦ê¤¤¥H«ü©wªº¦r¤¸§@¤À³Î¶Ç¦^¤@ºû°}¦C
  3.     Dim A As String, W, xi As Integer, i As Integer
  4.     A = "1ABCD2ABCD3ABCD4ABCD"
  5.     For xi = 2 To 6
  6.         W = Split(A, Mid(A, xi, 1))
  7.         For i = 0 To UBound(W)
  8.             Debug.Print W(i)     '¦b§Y®É¹Bºâµøµ¡¥i¨£
  9.         Next
  10.         MsgBox Join(W, ",")
  11.     Next
  12. End Sub
½Æ»s¥N½X
¦^´_ 12# c_c_lai
¨Ï¥Î VBA.Split »P ¨ç¼Æ¤§ Split ¹ê°ÈÀ³¥Î¤W¨ì©³¦³¦ó®t²§  ¤@¼Ëªº«áªÌ¥u¬O¬Ù²¤ªº¼gªk

TOP

¥»©«³Ì«á¥Ñ HSIEN6001 ©ó 2012-7-13 15:34 ½s¿è

¦^´_ 13# GBKEE

    ¤£¦n·N«ä!
¦]¬°³o°ÝÃD¬O #4 ¼Óªº©µ¦ù
©Ò¥H³Â·Ðª©¤j¦AÀ°§Ú¬Ý¬Ý
¨ú±o­ì©l½X¬°XÅܼÆ


Left(VBA.Split(.responseText, "filename' value='")(1), InStr(VBA.Split(.responseText, "<table class='noBorder")(1), ">"))
½Ð°Ý,¸Ó¥y»yªk­×©w
  1. Sub EX()
  2. Dim xml As New XMLHTTP
  3. Dim stream As New ADODB.stream
  4. Dim strURL As String
  5. Dim x As String
  6.     strURL = "http://mops.twse.com.tw/mops/web/ajax_t108sb27?step=1&firstin=ture&off=1&TYPEK=sii&co_id_1=&co_id_2=&year=" & _
  7.                 Year(Date) - 1911 & "&month=&b_date=&e_date=&type=1&rulesubmit2=%20%E6%90%9C%E5%B0%8B%20"
  8.         With xml
  9.             .Open "GET", strURL, 0
  10.             .send
  11.             Do While xml.ReadyState <> 4
  12.             Loop
  13.             x = Left(VBA.Split(.responseText, "filename' value='")(1), InStr(VBA.Split(.responseText, "<table class='noBorder")(1), "<"))
  14.         End With
  15. End Sub
½Æ»s¥N½X

TOP

¦^´_ 13# GBKEE

³o½d¨Ò,§ÚÁٻݭn¦AGoogle ¤Î®ø¤Æ§l¦¬
¤@ºû°}¦C & UBound(W) ?!
©¡®É­YÁÙ¤£À´¡A¦A½Ð±Ðª©¤j

xi=2 , Mid(A,2,1)=A , Split(1ABCD2ABCD3ABCD4ABCD,A)=1  , A¬°¤À³Î¤§¬É?
xi=3 , Mid(A,3,1)=B , Split(1ABCD2ABCD3ABCD4ABCD,B)=BCD2
xi=4 , Mid(A,4,1)=C , Split(1ABCD2ABCD3ABCD4ABCD,C)=BCD3
xi=5 , Mid(A,5,1)=D , Split(1ABCD2ABCD3ABCD4ABCD,D)=BCD4
xi=6 , Mid(A,3,1)=2 , Split(1ABCD2ABCD3ABCD4ABCD,2)=BCD

TOP

¦^´_ 13# GBKEE
  1. Option Explicit
  2. Sub Ex() 'Split¦b¦r¦ê¤¤¥H«ü©wªº¦r¤¸§@¤À³Î¶Ç¦^¤@ºû°}¦C
  3.     Dim A As String, W, xi As Integer, i As Integer
  4.     A = "1ABCD2ABCD3ABCD4ABCD"
  5.     For xi = 2 To 6
  6.         W = Split(A, Mid(A, xi, 1))
  7.         For i = 0 To UBound(W)
  8.         Debug.Print W(i)     '¦b§Y®É¹Bºâµøµ¡¥i¨£
  9.         Next
  10.         ' MsgBox Join(W, ",")
  11.         MsgBox "(For " & xi & " To 6)" & Chr(10) & Chr(13) & "(For i = 0 To " & UBound(W) & ")" & Chr(10) & Chr(13) & _
  12.                                          " Split(" & A & ", Mid(A, " & xi & ", 1)) -> " & "'" & Mid(A, xi, 1) & "'" & _
  13.                                          Chr(10) & Chr(13) & "Join(W, ', ') -> " & Join(W, ",")
  14.     Next
  15. End Sub

  16. ' (For 2 to 6)
  17. ' (For i = 0 To 4)
  18. ' Split("1ABCD2ABCD3ABCD4ABCD",Mid(A,2,1)) -> 'A'
  19. ' Join(W,',') -> 1,BCD2,BCD3,BCD4,BCD
  20. '
  21. ' (For 3 to 6)
  22. ' (For i = 0 To 4)
  23. ' Split("1ABCD2ABCD3ABCD4ABCD",Mid(A,3,1)) -> 'B'
  24. ' Join(W,',') -> 1A,CD2A,CD3A,CD4A,CD
  25. '
  26. ' (For 4 to 6)
  27. ' (For i = 0 To 4)
  28. ' Split("1ABCD2ABCD3ABCD4ABCD",Mid(A,4,1)) -> 'C'
  29. ' Join(W,',') -> 1AB,D2AB,D3AB,D4AB,D
  30. '
  31. ' (For 5 to 6)
  32. ' (For i = 0 To 4)                   <---   ¥¿½TÀ³¬° For i = 0 To 3
  33. ' Split("1ABCD2ABCD3ABCD4ABCD",Mid(A,5,1)) -> 'D'
  34. ' Join(W,',') -> 1ABC,2ABC,3ABC,4ABC
  35. '
  36. ' (For 6 to 6)
  37. ' (For i = 0 To 1)
  38. ' Split("1ABCD2ABCD3ABCD4ABCD",Mid(A,6,1)) -> '2'
  39. ' Join(W,',') -> 1ABCD.ABCD3ABCD4ABCD
½Æ»s¥N½X
ÁÂÁ±zªº½d¨Ò¡A²©ú§ã­n¡C
¸g´ú¸Õ¡A For 5 to 6 ªº°j°é®É¡A¦]¸Ó A ¦r¦ê§ÀºÝ¦r¤¸¬° D¡A
¥B Split(A, Mid(A,5,1)) ¤S¬° D ®É¡A UBound(W) ·|§P©w¬° 4¡A
¦]¬° W(4) = ""¡C ¦pªG¨Ï¥Î UBound(W) ¨Ó°µ³B²z´N·|¦³ Bug ¤F¡C

TOP

¦^´_ 13# GBKEE

²×©ó·N·|³o½d¨Ò
xi=2 , Mid(A,2,1)=A , W=Split(1ABCD2ABCD3ABCD4ABCD,A)=4 ­Ó A , UBound(W)=4 , For i = 0 To 4
  «h W(0)=1 , W(1)=BCD2 , W(2)=BCD3 , W(3)=BCD4 , W(4)=BCD

xi=3 , Mid(A,3,1)=B , w=Split(1ABCD2ABCD3ABCD4ABCD,B)=4 ­Ó B , UBound(W)=4 , For i = 0 To 4
  «h W(0)=1A , W(1)=CD2A , W(2)=CD3A , W(3)=CD4A , W(4)=CD

xi=4 , Mid(A,4,1)=C , w=Split(1ABCD2ABCD3ABCD4ABCD,C)=4 ­Ó C , UBound(W)=4 , For i = 0 To 4
  «h W(0)=1AB , W(1)=D2AB , W(2)=D3AB , W(3)=D4AB , W(4)=D

xi=5 , Mid(A,5,1)=D , w=Split(1ABCD2ABCD3ABCD4ABCD,D)=4 ­Ó D , UBound(W)=4 , For i = 0 To 4
  «h W(0)=1ABC , W(1)=2ABC , W(2)=3ABC , W(3)=4ABC , W(4)=ªÅ­È

xi=6 , Mid(A,3,1)=2 , w=Split(1ABCD2ABCD3ABCD4ABCD,D)=1 ­Ó 2 , UBound(W)=1 , For i = 0 To 1
  «h W(0)=1ABCD , W(1)=ABCD3ABCD4ABCD

¦nÃø³á!»Ý­n®ø¤Æ.....«Ü¤[!
³½¤£¦pº®,ÁÂÁª©¤jªº½d¨Ò»¡©ú

===========================
¦A¨Ó¦Û¸Ñ°ÝÃD
InStr¨ç¼Æ¥iªð¦^¤@­Ó¦r¦ê¦b¥t¤@­Ó¦r¦ê¤¤­º¦¸¥X²{ªº¦ì¸m¡C
Split¦b¦r¦ê¤¤¥H«ü©wªº¦r¤¸§@¤À³Î¶Ç¦^¤@ºû°}¦C¡C
»Ý¨D¬O t108sb27_20120712_17145551.csv

»yªk­×§ï«e:Left(VBA.Split(.responseText, "filename' value='")(1), InStr(VBA.Split(.responseText, "<table class='noBorder")(1), "<"))

VBA.Split(.responseText, "filename' value='")=t108 ¶}©l
InStr(VBA.Split(.responseText, "<table class='noBorder")(1),"<")
¦]¬°¨â¬q¸¨¤§¶¡¦³Alt+Enter

©Ò¥Hµ¹¤F³o­Ó­È -1
(InStr(VBA.Split(.responseText, "<table class='noBorder")(1),"<")-1)
RUNµ²ªG¤£¹ï­C!

­Y¹J¤W¦r¦ê¶¡¦³­ÓAlt+Enter ¸Ó¦p¦ó³B²z??  ³oºÃ°Ý©|¥¼¸Ñ¨M
<input type='hidden' name='filename' value='t108sb27_20120712_17145551.csv'>
<table class='noBorder' align='center' width='100%'><tr><td align='left'>

¦A½Ð±Ð Split(¦r¦ê,¤À³Î¦r¤¸)(1)--->³o­Ó(1)¬O?·N«ä

TOP

¦^´_ 16# c_c_lai
(For i = 0 To 4)                   <---   ¥¿½TÀ³¬° For i = 0 To 3
' Split("1ABCD2ABCD3ABCD4ABCD",Mid(A,5,1)) -> 'D'  ³o¸Ì¨Ã¨S¦³®M¤J i  ³oÅܼÆ
¥i¥H¶Ç¤W§A©Ò»¡ªº¿ù»~ µ{¦¡½X

¦^´_ 17# HSIEN6001
  1. Sub Ex()
  2.     Dim strURL As String, x As String
  3.     strURL = "http://mops.twse.com.tw/mops/web/ajax_t108sb27?step=1&firstin=ture&off=1&TYPEK=sii&co_id_1=&co_id_2=&year=" & _
  4.                 Year(Date) - 1911 & "&month=&b_date=&e_date=&type=1&rulesubmit2=%20%E6%90%9C%E5%B0%8B%20"
  5.         With CreateObject("Microsoft.XMLHTTP")
  6.             .Open "GET", strURL, 1
  7.            .send
  8.             Do While .ReadyState <> 4
  9.             Loop
  10.              x = Left(VBA.Split(.responseText, "filename' value='")(1), InStr(VBA.Split(.responseText, "<table class='noBorder")(1), "<"))
  11.            MsgBox x
  12.         End With
  13. End Sub
  14. Sub Ex_Split() 'Split(¦r¦ê,¤À³Î¦r¤¸)(1)--->³o­Ó(1)¬O?·N«ä
  15.     Dim A As String, W, xi As Integer, i As Integer
  16.     A = "1ABCD2ABCD3ABCD4ABCD"
  17.     W = Split(A, "B")
  18.     For i = 0 To UBound(W)
  19.         MsgBox "W(" & i & ")  -> " & W(i)
  20.     Next
  21. End Sub
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ HSIEN6001 ©ó 2012-7-15 17:50 ½s¿è

¦^´_ 18# GBKEE

µ{¦¡½X¦b#14¼Ó

­YÅã¥Ü¦b[A1]
  1. Sub EX()
  2. Dim xml As New XMLHTTP
  3. Dim stream As New ADODB.stream
  4. Dim strURL As String
  5.     strURL = "http://mops.twse.com.tw/mops/web/ajax_t108sb27?step=1&firstin=ture&off=1&TYPEK=otc&co_id_1=&co_id_2=&year=" & _
  6.                 Year(Date) - 1911 & "&month=&b_date=&e_date=&type=1&rulesubmit2=%20%E6%90%9C%E5%B0%8B%20"
  7.         With xml
  8.             .Open "GET", strURL, 0
  9.             .send
  10.             Do While xml.ReadyState <> 4
  11.             Loop
  12.             [A1] = Left(VBA.Split(.responseText, "filename' value='")(1), InStr(VBA.Split(.responseText, "<table class='noBorder")(1), "<"))
  13.             
  14.         End With
  15. End Sub
½Æ»s¥N½X
¤£ª¾¬°¦ó¦³®ÉOK~¦³®É¤£¦æ?!


§Ú¬O°Ñ¦Ò#2 ¼Ó»yªk
Rng.Offset(0, 1) = Left(VBA.Split(.responseText, "KK</span>")(1), InStr(VBA.Split(.responseText, "KK</span>")(1), "]"))
­×§ï¦Ó¨Óªº
Left(VBA.Split(.responseText, "filename' value='")(1), InStr(VBA.Split(.responseText, "<table class='noBorder")(1), "<"))

Split(¦r¦ê,¤À³Î¦r¤¸)(1)--->³o­Ó(1)¬O?·N«ä
¬Ý¤£À´(1)ªº§@¥Î

TOP

¦^´_ 18# GBKEE

Split(¦r¦ê,¤À³Î¦r¤¸)(1)--->³o­Ó(1)¬O?·N«ä
¬Ý¤£À´(1)ªº§@¥Î  , §Ú¬O°Ñ¦Ò#2 ¼Ó»yªk
Rng.Offset(0, 1) = Left(VBA.Split(.responseText, "KK</span>")(1), InStr(VBA.Split(.responseText, "KK</span>")(1), "]"))
­×§ïÀ³¥Î Left(VBA.Split(.responseText, "filename' value='")(1), InStr(VBA.Split(.responseText, "<table class='noBorder")(1), "<"))

¤£¦n·N«ä!§Úªí¹F¤£°÷²M·¡
À£ÁYÀɤº¦³¨â­Ó¤U¸ü,¤@­Ó¬ONG,¤@­ÓOK
¤£ª¾¬°¦ó¦³®É·|NG
´ú¸Õ-¬Y¦¸NGµ²ªG.rar (147.33 KB)

TOP

        ÀR«ä¦Û¦b : ¬O«D·í±Ð¨|¡AÆg¬ü§@ĵ±§¡C
ªð¦^¦Cªí ¤W¤@¥DÃD