我有一个这样的文本文件:
EntityList = 0x04A4BA64
LocalPlayer = 0x00A30504
FlashDuration = 0x0000A2F8
RadarBase = 0x04E807BC
ScoreBoardBase/GameResources = 0x04A6BCBC
ServerBase = 0x04E92A10
EnginePointer = 0x005B6314
SetViewAngles = 0x00004D0C
CrosshairIndex = 0x0000AA44
GlowObjectBase = 0x00000000
ViewMatrix1 = 0x04A3D604
ViewMatrix2 = 0x04A3D714
我想从我的vb.net程序中读取文本文件,例如,在第一行显示EntityList = 0x04A4BA64,我很乐意从它获取0x04A4BA64并将其保存为整数。
我试图做这样的事情,但这不是我真正想要的,也不是。
Public Sub Test()
Dim reader As New System.IO.StreamReader("C:\test.txt")
Dim allLines As List(Of String) = New List(Of String)
Do While Not reader.EndOfStream
allLines.Add(reader.ReadLine())
Loop
reader.Close()
End Sub
Public oEntityList As Integer = ReadLine(1, allLines)
答案 0 :(得分:2)
您需要打开文件并仅选择包含您的模式的行,然后将该行的第二部分转换为给定基数16的整数
Dim values = new List(Of Integer)()
For Each line in File.ReadLines("C:\test.txt") _
.Where(Function(x) x.Trim().StartsWith("EntityList"))
Dim parts = line.Split("="c)
if parts.Length > 1 Then
values.Add(Convert.ToInt32(parts(1).Trim(), 16)
End If
Next