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

[µo°Ý] .READLineªº¥Îªk

[µo°Ý] .READLineªº¥Îªk

.READLine¥u¯à¨Ì§ÇŪ¨ú¤@¦æ¦æªº¸ê®Æ¶Ü?¦pªG§Ú·Q­nŪ¨ú³Ì«á¤@¦æªº¸ê®Æ¶}¦p¦ó¼g©O?
½d¨Ò: test.txtÀÉ:
----------------
3
4
5
(ªÅ¥Õ)
(ªÅ¥Õ)
8
ECMA-74 +
----------------
§Ú·Q­nŪ¨ú³Ì«á¤@¦æ(§YECMA-74 +)¸Ó¦p¦ó¼g©O?

¦^´_ 1# acdx

§A«üªºReadlineÀ³¸Ó¬O«ü¥ÎFileSystemObjectªº¤èªk§a¡H
§A¥i¥H°Ñ¦Ò³o½g¡AHow Can I Read Just the Last Line of a Text file?

À³¸Ó¨S¦³¿ìªk"ª½±µ"¥uŪÀɮ׳̫á¤@¦æ¡A¦ý¬O¥i¥H¤@¦æ¤@¦æŪª½¨ì¨ú±o³Ì«á¤@¦æ¡C
¤£¹L§Ú¤£ª¾¹D§Aªº§xÂZ¬O¤£¬OÀɮ׫D±`¤j¡A¤@¦æ¤@¦æŪ¤ÓºC¡A­Y¬O³o­ì¦]¡A¤]¥i¥H¤@¦¸Åª§¹¦A¤Ï¦V§ä´«¦æ¦r¤¸(­n¬Ý§AÀɮתº´«¦æ¦r¤¸¬O­þ¤@ºØ)

TOP

¦^´_ 1# acdx
  1. Option Explicit
  2. Sub Ex()
  3.     Dim i As Integer, objFile As Object, A As Variant, E As Variant
  4.     Set objFile = CreateObject("Scripting.FileSystemObject")
  5.     Set objFile = objFile.OpenTextFile("D:\Test.txt", 1)
  6.     A = objFile.READALL
  7.     A = Replace(A, vbCr, "")     '®ø°£´_¦ì¦r¤¸
  8.     A = Split(A, "ECMA-74 +")(0) '¨ú±o"ECMA-74 +"¤§«eªº¦ê
  9.     A = Replace(A, vbLf & vbLf, vbLf)  '®ø°£ªÅ¥Õ¦C
  10.     A = Split(A, vbLf)
  11.     For i = 0 To UBound(A) - 1
  12.         MsgBox A(i)
  13.     Next
  14. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 3# GBKEE
G¤j §Ú§Æ±æªº¬O¥i¥HŪ¨ú³Ì«á¤@¦æªº­È¡A¥¦¬O¥¼ª¾ªº¡A¥i¯à¬O"ECMA-74 +"¤]¥i¯à¬O"ABCD"

TOP

¦^´_ 4# acdx
Ū¨ú³Ì«á¤@¦æªº­È
¬OÀɮתº³Ì©³³¡ªº¨º¤@¦æ¶Ü?

ÁÙ¬O¨º¤@¦æªº¥i¯à¬O"ECMA-74 +"¤]¥i¯à¬O"ABCD" ,¤£¬OÀɮתº³Ì©³³¡ªº¨º¤@¦æ?
³o¦r¦ê¦³©T©w¬O¨º¨Ç¦r¦ê¶Ü?
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 5# GBKEE
¬OÀɮתº³Ì©³³¡¤@¦æ
¥¦¥i¯àªº¦r¦ê¦³3ºØ:ECMA-74+, Normal, frequency

TOP

¦^´_ 6# acdx
¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Sub Ex()
  3.     Dim i As Integer, objFile As Object, A As Variant
  4.     Set objFile = CreateObject("Scripting.FileSystemObject")
  5.     Set objFile = objFile.OpenTextFile("D:\Test.txt", 1) '¶}±Ò¤å¦rÀÉ
  6.     A = objFile.READALL      'Ū¨ú¤å¦rÀÉ¥þ³¡¦r¦ê
  7.     Do While InStr(A, vbCrLf) Or InStr(A, vbLf & vbLf)
  8.         A = Replace(A, vbCrLf, vbLf)      '®ø°£´_¦ì¦r¤¸
  9.         A = Replace(A, vbLf & vbLf, vbLf) '®ø°£ªÅ¥Õ¦C
  10.     Loop
  11.     If Mid(A, Len(A)) = vbLf Then A = Mid(A, 1, Len(A) - 1) '²M°£³Ì«á¦r¤¸¬O´«¦æ¦r¤¸¡C
  12.     A = Split(A, vbLf)  'Àɮפ¤¦³¸ê®Æªº¦æ,¸m¤J°}¦C
  13.     MsgBox A(UBound(A)) 'Àɮתº³Ì«á¦³¸ê®Æªº¨º¤@¦æ
  14. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 1# acdx

§A·Q¦b­þ­Ó¦sÀx®æ内Åã¥Ü¡A´Nª½±µ¿é¤J¤U­±ªº¤½¦¡
¦pªG¼Æ¾Ú¦bAÄæ
    =LOOKUP(1,0/(A:A<>""),A:A)

¦pªG¼Æ¾Ú¦bBÄæ
    =LOOKUP(1,0/(B:B<>""),B:B)

¦p¦¹Ãþ±À

TOP

        ÀR«ä¦Û¦b : ¦³Ä@©ñ¦b¤ß¸Ì¡A¨S¦³¨­Åé¤O¦æ¡A¥¿¦p¯Ñ¥Ð¤£¼½ºØ¡A¬Ò¬OªÅ¹L¦]½t¡C
ªð¦^¦Cªí ¤W¤@¥DÃD