我需要将两个玩家的分数存储在一个文本文件中。然后我需要模拟掷骰子,对掷骰子的结果进行计算,并在文本文件中修改玩家的分数。到目前为止,要创建文本文件,我有下面的代码。任何有关如何在掷骰子后更新分数的帮助将不胜感激。
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim filepath As String = "H:\SomeFileName.txt"
If Not System.IO.File.Exists(filepath) Then
System.IO.File.Create(filepath).Dispose()
End If
Dim ObjFso
Dim StrFileName
Dim ObjFile
StrFileName = "H:\SomeFileName.txt"
ObjFso = CreateObject("Scripting.FileSystemObject")
'Creating a file for writing data
ObjFile = ObjFso.CreateTextFile(StrFileName)
'Writing a string into the file
ObjFile.WriteLine("Player 1")
ObjFile.WriteLine("Player 2.")
'Closing the file
ObjFile.Close()
End Sub
End Class