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

[µo°Ý] ¥ÎVBA¾Þ§@txtÀɮפ¤(¦b¯S©w¦ì¸m¿é¤J/¿é¥X)

[µo°Ý] ¥ÎVBA¾Þ§@txtÀɮפ¤(¦b¯S©w¦ì¸m¿é¤J/¿é¥X)

¥Ñ©ó¤§«e¤@ª½³£§â¬¡­¶Ã¯·í¦¨¸ê®Æ®w¨Ó¨Ï¥Î

¦ý³Ìªñ¦]¬°©Ò»Ý¦æ¼Æ¤w¸g¶W¥X¬¡­¶Ã¯ªº³Ì¤j¦æ¼Æ

©Ò¥H·Q­n§â¬¡­¶Ã¯·í¦¨¸ê®Æ®wªº¤è¦¡§ï¦¨.txtÀÉ

·Q½Ð±ÐªO¤W¦U¦ì«e½ú,­n¦p¦ó°w¹ïtxtÀɸ̭±ªº¤º®e§@¾Þ§@©O?

Á|¨Ò¨Ó»¡:

·Q±N ¦b³Ì«á¤@¦æ¥[¤J¨ä¥L¸ê®ÆÅܦ¨

¦ý§Æ±æ¬O¯à°÷ª½±µ¦b²Ä¤@­ÓÀÉ®×ÂনtxtÀɤ¤¾Þ§@(¤£¦AŪ¨ú¨ìexcel·í¤¤),

¤]´N¬O­n±N°O¨Æ¥»¤¤ªºÀÉ®×¥Ñ Åܦ¨

¥i¥H½ÐªO¤W«e½ú«üÂI¤@¤U¶Ü?ÁÂÁÂ

§ï§ï²Ä11¦æªºÀɦW:
  1. Sub Read_text_File()

  2. Dim oFSO
  3. Set oFSO = CreateObject("Scripting.FileSystemObject")


  4. Dim itemCount As Long
  5. Dim lumSum As Long
  6. Dim filename As String

  7. filename = "c:\temp\readfile.txt"

  8. Set oFS = oFSO.OpenTextFile(filename)

  9. Do Until oFS.AtEndOfStream
  10. sText = oFS.ReadLine
  11. itemCount = UBound(Split(sText, ","))
  12. lumSum = lumSum + Int(Split(sText, ",")(itemCount))
  13. Loop
  14. oFS.Close

  15. Set oFS = oFSO.OpenTextFile(filename, 8, , 0)
  16. oFS.WriteLine
  17. oFS.Write String(itemCount, ",") & Trim(Str(lumSum))
  18. oFS.Close

  19. oFSO = Null
  20. End Sub
½Æ»s¥N½X
À´±oµo°Ý,µª®×´N·|¦b¨ä¤¤

¤µ¤éの¤@¬íは  ©ú¤éにない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

¥»©«³Ì«á¥Ñ luhpro ©ó 2010-7-22 22:23 ½s¿è

·Ó¬Ý§Aªº»Ý¨D­Y¨Ï¥Î .txt ®æ¦¡ªº¤å¦rÀɨӦs¨ú¸ê®Æ¥i¯à·|¦³¤@¨ÇÄpµ²ÂI»Ý­n¦Ò¼{¶i¥h.

1. ¤£¾A¦X³æ¿W§ì¨ú¬Y¤@¦æ¸ê®Æ¥X¨ÓÅܧó«á¦A¦s¤JÀÉ®×.

¦]¬° .txt ®æ¦¡ªº¤å¦rÀɮ׬O¤@¯ë©Ò¿×ªº´`§ÇÀÉ,
¥ç§Y­nŪ¨ú(©Î¼g¤J)¸ê®Æ®É»Ý­n "±qÀY¦Ü§À" Ū¨ú(©Î¼g¤J). (PS. ¨C¤@¦¸¦s¨ú³£­n­«½Æ¤@¦¸)
µM¦Ó§Aªº¸ê®Æ¶q«ÜÅãµMªºÀ³¸Ó¨Ã¤£¤p,
¨º»ò¸ê®Æ³B²z»PŪ¼gªº®É¶¡´N¤£·|¤Ö¤F,
¦Ó¥BÀWÁcªº¦s¨ú¾ã­Ó³æ¤@ÀÉ®×,
µwºÐ¥i¬O¤ñ¸û®e©ö¥X²{Ãa­yªº³á.

2. ¨º»ò­n¨Ï¥Î.txt ®æ¦¡ªº¤å¦rÀɮ׸û¥i¦æªº¤è¦¡,
´N¬Oµ{¦¡¶}©l®É"±qÀY¦Ü§À"Ū¤@¦¸¸ê®Æ©ñ¦b°O¾ÐÅ餤,
­×§ï®Éª½±µ­×§ï°O¾ÐÅé¤Wªº¸ê®Æ,
½s¿è§@·~µ²§ô«e¦A¤@¦¸"±qÀY¦Ü§À"±N©Ò¦³¸ê®Æ¨Ì§Ç¼g¤JÀɮפ¤.
¶·¦Ò¼{ªº¬O¸ê®Æ­n¥H¦óºØ§Î¦¡©ñ¦b°O¾ÐÅé¤W?
§Ú·Q¸û¥i¦æªº¤è¦¡¬O¨Ï¥ÎÃìµ²¦ê¦C.

3. ¦Ó­Y¤£°í«ù¨Ï¥Î .txt ¤å¦rÀɮ׮榡ªº¸Ü,
§Ú·|«Øij±Ä¥ÎÀH¾÷ÀÉ,
¥ç§Y "©T©w" ¨C¤@µ§¸ê®Æ(Excel¤Wªº¨C¤@¦C ©Î .txt Àɤ¤ªº¨C¤@¦æ)ªº¤j¤p,
µM«á¨C¦¸½s­×®É¥uŪ¨ú¬Y¤@µ§¸ê®Æ -> ­×§ï¤º®e -> ¦A¦s¤J¸Óµ§¸ê®Æ.

4. ÁÙ¦³¤@­Ó¤è¦¡¬O·í¸ê®Æµ§¼Æ¹F¨ì¬¡­¶Ã¯³Ì¤j®e³\¶q®É¦A·s¼W¤@­Ó¬¡­¶Ã¯¨Ó¦s©ñ¤U¤@°Ï¶ôªº¸ê®Æ,
©Î¬O§ï¦s¨ì¥t¤@­ÓExcelÀɤº,
·íµM...³B²z»P¦s¨ú¸ê®Æªº¤½¦¡·|Åܪº¤ñ¸û½ÆÂø.

5. ³Ì«á§Ú¥i¥H·Q¨ìªº¤è¦¡´N¬O ªáÂI¿ú§ï¥Î Access ¨Ó¦s©ñ¸ê®Æ§a.

TOP

·PÁ L¤jªº«Øij

¤p§Ì¥Ø«e¨Ï¥Î²Ä4­Ó¸Ñ¨M¤è®×

«á¨Ó·Q¤F¤@¤U,txtÀɮתº¾Þ§@¤W¯uªº¬Û¹ï§xÃø

ÁöµM§Úªº»Ý¨D¥u¬O¥Îappend±N¸ê®Æ¼g¦b³Ì«á­±,µM«á¦A±N¥LŪ¥X¨Ó

©Ò¥H¼g¤J¨ä¹ê¨S¦³¤Ó¦h°ÝÃD,¦ý¤@¸I¨ì­nŪ¨ú´N«Ü³Â·Ð¤F@@"

·PÁÂ

TOP

        ÀR«ä¦Û¦b : ¦Y­W¤F­W¡B­WºÉ¤Ü¨Ó¡A¨ÉºÖ¤FºÖ¡BºÖºÉ´d¨Ó¡C
ªð¦^¦Cªí ¤W¤@¥DÃD