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

¨Ï¥Î Line Input #1, mystr ¤¤¤å¦r·|Åܦ¨¶Ã½X,½Ð°Ý¦³¤èªk§JªA¶Ü?

¨Ï¥Î Line Input #1, mystr ¤¤¤å¦r·|Åܦ¨¶Ã½X,½Ð°Ý¦³¤èªk§JªA¶Ü?

½Ð°Ý¦U¦ì¦³¹J¨ì¹L³o¼Ëªº°ÝÃD¶Ü?

Open myfile For Input as #1
       Line input #1,  mystr
Close #1

­Y mystr ¦³¤¤¤å½X,³£·|Åܦ¨¤@³s¦êªº?¸¹,½Ð°Ý¥i¥H§JªA¶Ü?
V98

¦^´_ 1# linshin1999


    ¤£ª¾¹D§A¼g¤J¦b¬Æ»ò¦a¤è
¥Î§Y®É¹Bºâµøµ¡±o¨ìµª®×¡A«Ü¥¿±`ªº
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

HsiehªO¥D:

§Úªº¤å¦rÀɬO±qVB²£¥Í¥X¨Óªº,±q°O¨Æ¥»¤¤¥i¥H¬Ý¨ì§¹¾ãªº¤å¦rÀÉ,¦ý¬O±qExcelŪ¶i¨Ó¹J¨ì¤¤¤å¦r·|Åܦ¨¶Ã½X.

myinx = 0
Open muti_f For Input As #1
        Do Until EOF(1)
            Line Input #1, mystr
            myinx = myinx +1
            mylist(myinx) = mystr
            muti_count = muti_count + 1
        Loop
    Close #1

·|¬O³]©wªº°ÝÃD¶Ü?
V98

TOP

¦^´_ 3# linshin1999

§AªºTXT½s½X¬OUnicode§a
ÂনANSI½s½X¸Õ¸Õ¬Ý
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

HsiehªO¥D§A¦n:

¤£ª¾¹DVB¤¤ªº½s½Xªº¤è¦¡¬°¦ó,¦ý¬O¦pªG¬OUnicodeªº¸Ü,¦p¦óÂà´«¦¨Ansi ©O?
V98

TOP

¦^´_ 5# linshin1999


    test.gif
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¥»©«³Ì«á¥Ñ linshin1999 ©ó 2011-3-19 20:18 ½s¿è

¦^´_ 6# Hsieh
HsiehªO¥D§A¦n:

°ÝÃD¸Ñ¨M¤F,§ÚªºVB­ì©l³]©w¬O(UTF-8),ÁöµM³o¼Ë¥i¥H¦ý¬O¬O¤£¬O¨C¦¸³£­n°µ³o¼ËªºÂà´«©O?
¥t¥~¦b Line Input ³oÃä¸Ñ¨M¤F,¦ý¬O·|¦b滙¤JÀɮרºÃä·|¥X°ÝÃD,³oÃä¾A¦X¥Î(UTF-8),¤£µM·|¶Ã½X.¶×¤JÀɮתºµ{¦¡¦p¤U:

With ActiveSheet.QueryTables.Add(Connection:=input_file, Destination:=Range("$A$1"))
        .Name = "ªíÀY"
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SaveData = True
        .AdjustColumnWidth = True
        .TextFilePlatform = 65001
        .TextFileStartRow = 1
        .TextFileParseType = xlFixedWidth
        .TextFileColumnDataTypes = Array(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
        .TextFileFixedColumnWidths = Array(2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
End With

³o¤@¬qµ{¦¡±µ¨ü(UTF-8),¦ÓLine Input¨ºÃä«h±µ¨ü(ANSI)³Â·Ð§a,¤£¹LÁ`¬O§â°ÝÃD§ä¥X¨Ó¤F,ÁÂÁ§A!!

¥t¥~§A¬O§_ª¾¹DVB¥i¦³±±¨î¿é¥X½Xªº¤èªk¶Ü?ÁÂÁÂ!!
V98

TOP

¥»©«³Ì«á¥Ñ linshin1999 ©ó 2011-3-19 23:16 ½s¿è

¦^´_ 6# Hsieh

HsiehªO¥D:

§Q¥Î Line Input # 滙¤JÀÉ®×,¬O¤£¬O¤Ó¦Ñ¦¡¤F,¥H«e¦n¹³¶Ã½X§xÂZ«Ü¦h¤H,±qOffice 2007 ¥H«á¦n¹³³Q§ïµ½¤F,¹³¥Î ActiveSheet.QueryTables.Add 滙¶i¨ÓªºÀÉ®×´N没°ÝÃD,·|¥Î Line input #, ¬O¦]¬°¨º¬O¤¤¶¡Àɪø«×¤£©T©w,¦Ó¥B¤£¬O­nª½±µ¥á¨ì Worksheet ¥h, ©Ò¥H¥Î Line input #, ¤£ª¾¹D¦³没¨ä¥L¤èªk¥i¥H滙¤JÀÉ®×(¹³Åª´`§ÇÀɨº¼Ë), ¦Ó¥B¥i¥H±µ¨ü UTF-8 ªº? ÁÂÁÂ!!
V98

TOP

¦^´_ 8# linshin1999
  1. Sub OpenTextFileTest()
  2.     Dim fs, f
  3.     Set fs = CreateObject("Scripting.FileSystemObject")
  4.     Set f = fs.getfile("C:\Users\Documents\testfile.txt") 'Unicode ®æ¦¡ÀÉ®×
  5.     Set ts = f.openastextstream(1, -1)
  6.     mystr = ts.readall 'Ū¨úUnicode ®æ¦¡ÀÉ®×
  7.     ts.Close
  8.     Set f = fs.getfile("C:\Users\Hsieh\Documents\testfile1.txt") 'ASCII ®æ¦¡ÀÉ®×
  9.     Set ts = f.openastextstream(2, 0)
  10.     ts.Write mystr '¼g¤JASCII ®æ¦¡ÀÉ®×
  11.     ts.Close
  12. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

Sub Ex()
    Application.DisplayAlerts = False
    With Workbooks.Open("D:\Test\¤å¥ó.txt") '¶}±Ò Unicode ®æ¦¡ÀÉ®×
            .SaveAs Filename:="D:\Test\Test.txt", FileFormat:=xlText
            '¥t¦s¬° ASCII ®æ¦¡ÀÉ®×
            .Close
    End With
    Application.DisplayAlerts = True
End Sub

TOP

        ÀR«ä¦Û¦b : ¤Ñ¤W³Ì¬ü¬O¬P¬P¡A¤H¥Í³Ì¬ü¬O·Å±¡¡C
ªð¦^¦Cªí ¤W¤@¥DÃD