Const adTypeBinary = 1 Sub Foo() bin = LoadBin("D:\misc\a.txt") n = GetBinSize(bin) Text = "" For i = 0 To n - 1 Text = Text + ChrW(CodeAt(bin, i)) Next index = InStr(Text, ChrW(&HFF)) MsgBox "最初に見つけた &HFF の位置: " + CStr(index) index = InStr(Text, "hello") MsgBox "最初に見つけた hello の位置: " + CStr(index) End Sub Function LoadBin(path) Set stm = CreateObject("ADODB.Stream") stm.Type = adTypeBinary stm.Open stm.LoadFromFile (path) LoadBin = stm.Read() stm.Close End Function Function GetBinSize(bin) GetBinSize = LenB(bin) End Function Function CodeAt(bin, index) CodeAt = AscB(MidB(bin, index + 1, 1)) End Function