Dim fileName As String = "C:\test\example.txt" Dim data()() As String = System.IO.File.ReadLines(fileName, _ System.Text.Encoding.GetEncoding("Shift_JIS")).Select(AddressOf Split).ToArray()
Dim fileName As String fileName = "C:\test\example.txt" Dim data() As Variant 'この変数に格納する Dim fno As Integer fno = FreeFile(0) Open fileName For Binary Access Read As #fno Dim lines() As String lines = Split(StrConv(InputB(LOF(fno), fno), vbUnicode), vbCrLf) Close #fno: fno = 0 ReDim data(UBound(lines)) As Variant Dim r As Long For r = LBound(data) To UBound(data) data(r) = Split(lines(r), " ") Next Erase lines
Option Explicit Dim fileName fileName = "C:\test\example.txt" Dim data 'この変数に格納する Const adTypeText = 2 Const adReadLine = -2 Dim d, stm Set d = CreateObject("Scripting.Dictionary") Set stm = CreateObject("ADODB.Stream") stm.Open stm.Type = adTypeText stm.Charset = "Shift_JIS" stm.LoadFromFile fileName Do Until stm.EOS d.Add CStr(d.Count), Split(stm.ReadText(adReadLine), " ") Loop stm.Close Set stm = Nothing data = d.Items() Set d = Nothing