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

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

¦^´_ 24# GBKEE
¦^´_ 21# c_c_lai

ÁÂÁ¨â¦ì¤j¤j«ü¾É
§Ú·|§V¤O®ø¤Æ
~·P®¦~^__^~

TOP

¦^´_ 23# c_c_lai
§ä¤£¥X§Aªº¿ù»~
  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 5 to 6)
  6.     For i = 0 To 4       '   <---   ¥¿½TÀ³¬° For i = 0 To 3
  7.         W = Split("1ABCD2ABCD3ABCD4ABCD", Mid(A, 5, i)) ' '-> 'D'
  8.     MsgBox "¤À³Î¦r¦ê """ & Mid(A, 5, i) & """°}¦C¤W­­ºû«× " & UBound(W) & " ³Ì«á¤@ºû¦r¦ê: " & W(UBound(W)) '-> 1ABC,2ABC,3ABC,4ABC)
  9.     Next
  10. End Sub
½Æ»s¥N½X
¦^´_ 20# HSIEN6001
Split(¦r¦ê,¤À³Î¦r¤¸)(1)--->³o­Ó(1)¬O?·N«ä
18#¦³¥Ü½dªºµ{¦¡
  1. Sub Ex_Split() 'Split(¦r¦ê,¤À³Î¦r¤¸)(1)--->³o­Ó(1)¬O?·N«ä
  2.     Dim A As String, W, xi As Integer, i As Integer
  3.     A = "1ABCD2ABCD3ABCD4ABCD"
  4.     W = Split(A, "B")
  5.     For i = 0 To UBound(W)
  6.         MsgBox "W(" & i & ")  -> " & W(i)
  7.     Next
  8. End Sub
½Æ»s¥N½X
À£ÁYÀɤº¦³¨â­Ó¤U¸ü,¤@­Ó¬ONG,¤@­ÓOK
21#c_c_lai  ¤£¬O»¡
²Ä¤@¦¸¤@©w¬O OK ªº¡A¦]¬°¦b D:\ ¤º ¥«.csv¡BÂd.csv ¨Ã¤£¦s¦b¡A«ö²Ä¤G¦¸®É¡A
©p¤S¦A¦¸¨Ï¥Î .SaveToFile (Apath & "¥«.csv") ¥H¤Î .SaveToFile (Apath & "Âd.csv")
©Ò¥H´N·|¥X¿ù¤F¡C
  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, y As String
  6. Dim Apath As String, ApathFile As String
  7. Apath = "D:\"
  8. If Dir(Apath & "¥«.csv") <> "" Then Kill Apath & "¥«.csv"       '¥[¤W¦³«h§R°£ªº§PÂ_
  9. If Dir(Apath & "Âd.csv") <> "" Then Kill Apath & "Âd.csv"
½Æ»s¥N½X

TOP

¦^´_ 18# GBKEE
§Ú«üªº¬O#16 ªº²Ä32¦æ
' (For 5 to 6)
' (For i = 0 To 4)                   <---   ¥¿½TÀ³¬° For i = 0 To 3
' Split("1ABCD2ABCD3ABCD4ABCD",Mid(A,5,1)) -> 'D'
' Join(W,',') -> 1ABC,2ABC,3ABC,4ABC,
'
10.png

TOP

¦^´_ 21# c_c_lai

¥u«ö¤@¦¸¦Ó¤w
µ{§Ç«á³B²z,¦³¤UKill «ü¥O§R°£ÀÉ®×
¦ý¤U¸ü¿ù»~ªº­¶­±,µLªk§¹¦¨©Ò¦³°Ê§@.

¥X²{¿ù»~ªº¤U¸ü   
<head>
<link rel='stylesheet' href='/ppp.css' type='text/css'>
</head>
<body>
<center>
<br><h4 align='center'><font color='red'>Àɮפ£¦s¦b</font></h4>
<!- filename1 = t108sb27_20120715_18181771.csv' --><br>
<!- filename2 = t108sb27_20120715_18181771.csv' -->
<!- fromNew =  -->

¤££¸©w¦b[¥«]or[Âd]¥X²{¿ù»~ªº¤U¸ü
¸ò¦^¶Ç³t«×¦³Ãö«Y?!

TOP

¥»©«³Ì«á¥Ñ c_c_lai ©ó 2012-7-15 20:52 ½s¿è

¦^´_ 20# HSIEN6001
²Ä¤@¦¸¤@©w¬O OK ªº¡A¦]¬°¦b D:\ ¤º ¥«.csv¡BÂd.csv ¨Ã¤£¦s¦b¡A«ö²Ä¤G¦¸®É¡A
©p¤S¦A¦¸¨Ï¥Î .SaveToFile (Apath & "¥«.csv") ¥H¤Î .SaveToFile (Apath & "Âd.csv")
©Ò¥H´N·|¥X¿ù¤F¡C
À³¸Ó¦b .SaveToFile() «e¥ý§PÂ_Àɮ׬O§_·~¤w¦s¦b¡A¦p¬Oªº¸Ü¡A´NÀ³¥ý¤©¥H§R°£«á¡A
¤~¯à°õ¦æ .SaveToFile()¡C
¦Ü©ó¦p¦ó¥h°õ¦æ§R°£°Ê§@(VBA »yªk)´N­n½Ð±Ð GBKEE ¤j¤j¤F¡C

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

¥»©«³Ì«á¥Ñ 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

¦^´_ 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

¦^´_ 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

¦^´_ 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

        ÀR«ä¦Û¦b : ¹ï¤÷¥À­nª¾®¦¡A·P®¦¡B³ø®¦¡C
ªð¦^¦Cªí ¤W¤@¥DÃD