我正在为一个项目开发 RPG 类型的游戏,但我被卡住了。
基本上,此代码在文本文件中搜索名称(结构:赔率作为名称,偶数作为级别)。然后它需要输出下一行,即他们所在的级别。我有计数器(变量“count”)来输出写入级别的正确文本行,但我不能使用该计数来读取该行(使用“FileSystem.LineInput(count)”)。
这是我的完整代码:
Sub LoadGame()
Dim filename, filepath, searchitem, question, read As String
Dim found As Boolean
Dim count As Integer = 1
filename = "save.txt"
filepath = CurDir() & "\" & filename
searchitem = name
FileOpen(1, filename, OpenMode.Input)
Do While Not EOF(1)
read = LineInput(1)
If read = searchitem Then
found = True
Exit Do
Else
found = False
End If
count = count + 1
Loop
If found = True Then
If count >= 3 Then
count = count + 1
End If
question = FileSystem.LineInput(count) ' This bit is broken
Console.WriteLine("Found save game... Loading: " & question)
Console.ReadLine()
Console.BackgroundColor = ConsoleColor.Black
Console.ForegroundColor = ConsoleColor.Red
Console.Clear()
Race(question)
Else
Console.WriteLine("No save game...")
Console.ReadLine()
End If
FileClose(1)
End Sub
我不确定出了什么问题,但任何帮助将不胜感激(使用 VB 2010)