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

¨Ï¥Îµ{¦¡±N°O¨Æ¥»¤º®e¾ã²z¸ê®Æ

¨Ï¥Îµ{¦¡±N°O¨Æ¥»¤º®e¾ã²z¸ê®Æ

½Ð°Ý¦U¦ì«e½ú,§Ú­n¦p¦ó¼gVBA±N°O¨Æ¥»¤ºªº¬õ¦â®Ø½u¾ã²z¦¨¤W­±®æ¦¡©Ò¥Ü ¡]¸Ô²Ó»¡©ú¦p¹Ï©Ò¥Ü,¬ÛÃö°O¨Æ¥»¦pªþ¥ó©Ò¥Ü)

°O¨Æ¥»¾ã²z.jpg (263.2 KB)

°O¨Æ¥»¾ã²z.jpg

°O¨Æ¥»¾ã²z.jpg (263.2 KB)

°O¨Æ¥»¾ã²z.jpg

txt.rar (482 Bytes)

  1. Sub Ex()
  2. Dim ay(9), Ary()
  3. fs = ThisWorkbook.Path & "\txt.txt"
  4. Open fs For Input As #1
  5. Do While Not EOF(1)
  6.    Line Input #1, mystr
  7.       If mystr = "#" Then tn = True: tk = False: GoTo 10
  8.       If tn = True And Not IsNumeric(Split(mystr, " ")(0)) Then ty = Split(mystr, " ")(0): tn = False: GoTo 10
  9.       If mystr = "%" Then tn = False: tk = True: GoTo 10
  10.       If tn = False And tk = True And Val(mystr) <> 0 Then
  11.          ar = Split(mystr, " ")
  12.          ay(0) = ty & ar(0)
  13.          For i = 1 To UBound(ar)
  14.             If ar(i) <> "" Then
  15.                j = j + 1
  16.                ay(j) = ar(i)
  17.             End If
  18.          Next
  19.          ReDim Preserve Ary(s)
  20.          Ary(s) = ay
  21.          s = s + 1: j = 0
  22.        End If
  23. 10
  24. Loop
  25. Close #1
  26. [A2].Resize(s, 9) = Application.Transpose(Application.Transpose(Ary))
  27. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 2# Hsieh
ÁÂÁª©¥D¦^ÂÐ,´ú¸Õµ²ªG¥i¥Î,¦ý¹ïµ{¦¡½X¦³¤U­±´XÂI·Q½Ð±Ð:
[1] tn,tk ¥Nªíªº¬O¤°»ò©O? ¥Ñµ{¦¡½X±ÀÂ_¬°true »Pfalse ¨âºØ,¥L¦b°O¨Æ¥»¤º ©Ò¥Nªíªº·N¸q¬O¤°»ò©O?
[2] µ{¦¡½X¤º: If tn = True And Not IsNumeric(Split(mystr, " ")(0)) ©Ò­nªí¹Fªº·NÃѬO§_¬° ±Nmystr ¦³ªÅ®æªº¦a¤è°µÂ^¨úªº°Ê§@,¦ý IsNumeric(Split(mystr, " ")(0))¤¤(0) ©Ò¥Nªíªº·N«ä¬O¤°»ò©O?

TOP

¦^´_ 3# jntseng
tn,tk   ¦b°O¨Æ¥»¤º ¤¤¨Ã¨S¦³·N¸q ¬Oµ{¦¡¥HÅܼƪºtrue ©Î false §@¬°¹B¦æªº±ø¥ó§PÂ_

Split ¬°¶Ç¦^¤@­Ó³¯¦C¯Á¤Þ±q¹s¶}©lªº¤@ºû°}¦C
Split(mystr, " ") =>¦bmystr¦r¦êÅܼƥH" "§@¬°¤À¹j²Å¸¹  ªº¤@ºû°}¦C
Split(mystr, " ")(0) => 0¦¹¤@ºû°}¦Cªº²Ä ¤@­Ó¤¸¯À ¥H¦¹Ãþ±À
Not IsNumeric(Split(mystr, " ")(0)) =>¶Ç¦^²Ä ¤@­Ó¤¸¯À¬O§_¬°¦r¦ê

   

TOP

¦^´_ 4# GBKEE
ÁÂÁª©¥Dªº¦^ÂÐ,¹ï©ótn,tk ÁÙ¬O¤£ÁA¸Ñ,§Ú·Q¥H¥t¥~¤@­Ó¨¤«×°Ý,­Yµ{¦¡½X¨S¦³tn,tkªº¸Ü,°õ¦æ·|¦³°ÝÃD¶Ü? ­Y¬O·|¦³°ÝÃDªº¸Ü,°ÝÃDÂI¦b­þ©O?

TOP

tn,tk¦¹2ÅܼƬO¥Î¨Ó°µºI¨ú¸ê®Æ¶}©l¤Î¤ù¬qµ²§ô¨Ì¾Ú
¥i¥ÑIf mystr = "#" Then tn = True: tk = False: GoTo 10
³o¦æ´N¬O#¨º¤@¦æ³QŪ¤J®É¡A¥Îtn§i¶Dµ{¦¡¤U¤@¦æ¶}©l´N¬O¸ê®Æ©ïÀY°Ï°ì
If mystr = "%" Then tn = False: tk = True
´N¬O©ú²Óªº¶}©l
¨S³o2­ÓÅܼƷíµM°õ¦æ¤£¨ÓÅo
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 6# Hsieh
ÁÂÁª©¥Dªº¦^ÂÐ,¹ï©ó§Aªº¦^ÂÐ,¦³¨Ç¤£À´,
·ítn=true,tk=false ªí¥Ü¸ê®Æ©ïÀY°Ï°ì,«üªº¬O¤°»ò? ¬O§_¥i¥Hµ§°O¥»ªº¤º®e»¡©ú©O
·ítn=false,tk=true ªí¥Ü¸ê®Æ©ú²Óªº¶}©l,«üªº¬O¤°»ò?¬O§_¥i¥Hµ§°O¥»ªº¤º®e»¡©ú©O
·|¤£·|¦³tn=true,tk=true or tn=false,tk=false ©O? ¥Nªíªº¬O¤°»ò©O?

TOP

´N¦]¬°tn,tkªº²Õ¦Xª¬ªp·|¦³¦hºØ²Õ¦X,©Ò¥H¯à¥Î¨Ó°µ¬°¸ê®ÆÂ^¨úªº¶}©l»Pµ²§ô§PÂ_¨Ì¾Ú
¹J¨ì#ªº¤U¤@¦æ¤å¦rT409P086AA01´N¬Oid¸¹½Xªº«e¸m¦r¦ê
¦³¤Fid¸¹½Xªº«e¸m¦r¦ê«á­Y¹J¨ì¸Ó¦æ¬°%±µ¤U¨Óªº¦U¦æ«e­±¬O¼Æ¦r®É
«h¸Ó¼Æ¦r»Pid¸¹½Xªº«e¸m¦r¦êªº²Õ¦X´N¬O¾ã²Õid½X
ª½¨ì¦b¦¸¹J¨ì#¤~¦A­«·s¨ú±oid¸¹½Xªº«e¸m¦r¦ê
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 8# Hsieh
ÁÂÁª©¥Dªº¸ÑÄÀ,§Ú¬O¤£¬O¥i¥H¸ÑÄÀ¬°#~%¤§¶¡ªí¥ÜTN=true,tk=flase
%~#¤§¶¡ªí¥ÜTN=flase,tk=true©O?

TOP

¨º­Ó§PÂ_¦¡«á­±¬O§Ú­Ì­n«ü©wÅܼƪº­È¬O¬Æ»ò?
¦Ó¤£¬O¨ú±o¨º®ÉªºÅܼƬO¬Æ»ò­È
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

        ÀR«ä¦Û¦b : ºÉ¦h¤Ö¥»¥÷¡A´N±o¦h¤Ö¥»¨Æ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD