数值模拟

来源:互联网 发布:查了啊网络电视直播 编辑:程序博客网 时间:2024/04/27 16:13
Public getTili As BooleanPublic buyTili As BooleanPublic cishu As IntegerPublic dengji As IntegerPublic tili As IntegerPublic jingyan As IntegerPublic zijin As LongPublic tianshu As IntegerPrivate Sub Check1_Click()If Check1.Value = 1 Then    'MsgBox "被选择"    getTili = TrueElse    'MsgBox "未被选择"    getTili = FalseEnd IfEnd SubPrivate Sub Check2_Click()If Check2.Value = 1 Then    'MsgBox "被选择"    buyTili = TrueElse    'MsgBox "未被选择"    buyTili = FalseEnd IfEnd SubPrivate Sub readButton_Click()FileNumber = FreeFileOpen "player.txt" For Input As #FileNumberDo While Not EOF(FileNumber)    Line Input #FileNumber, TextLine    temp = temp + TextLine + vbCrLf    showTxt.Text = tempLoopClose #FileNumberSet re = New RegExpre.Pattern = "等级:(\d+).*\n当前经验:(\d+).*\n当前体力:(\d+).*\n资金:(\d+).*\n可购买体力次数:(\d+)"If (re.Test(temp) = True) Then    Set re1 = re.Execute(temp)(0)    cishu = re1.SubMatches(4)    dengji = re1.SubMatches(0)    tili = re1.SubMatches(2)    jingyan = re1.SubMatches(1)    zijin = re1.SubMatches(3)    showMsgElse    MsgBox "文件错误"End IfEnd SubPublic Sub shuaFB()Debug.Print "刷副本"tili = tili - 6zj = 610 + 10 * Int(dengji / 5)zijin = zijin + zjDebug.Print "获得资金:" & zjjingyan = jingyan + 6End SubPublic Sub suanLevel()Dim a, b As IntegerSet re = New RegExpre.Pattern = "(\d+)\t(\d+)"FileNumber = FreeFileOpen "level.txt" For Input As #FileNumberDo While Not EOF(FileNumber)    Line Input #FileNumber, TextLine    If re.Test(TextLine) = True Then        Set re1 = re.Execute(TextLine)(0)        a = re1.SubMatches(0)        b = re1.SubMatches(1)        If a = dengji And b > jingyan Then            Close #FileNumber            Exit Sub        End If        If a = dengji And b <= jingyan Then            Debug.Print "Level UP"            dengji = dengji + 1            jingyan = jingyan - b            max_tili = dengji + 59            tili = tili + 20        End If    End IfLoop'Close #FileNumberEnd SubPublic Sub showMsg()levelTxt(0).Text = dengjijingyanTxt(2).Text = jingyantiliTxt(1).Text = tilimoneyTxt(3).Text = zijinEnd SubPrivate Sub runButton_Click()If (Text1.Text = "") Then    MsgBox "请输入天数"Else    tianshu = Text1.TextEnd IfFileNumber = FreeFileOpen "Log.txt" For Output As #FileNumberFor i = 1 To tianshu    Print #FileNumber, "====  第" + Str(i) + "天  ===="    temp = temp + "第" + Str(i) + "天:" + vbCrLf    tili = dengji + 59    getTili = True    buyTili = True    n = 0    While tili >= 6        Print #FileNumber, "角色等级:" + Str(dengji) + "  角色体力:" + Str(tili) + "  当前资金:" + Str(zijin)        shuaFB        n = n + 1        suanLevel        If tili < 6 And Check1.Value = 1 And getTili = True Then            tili = tili + 120            getTili = False            Print #FileNumber, "领取免费体力120点"        End If        If tili < 6 And Check2.Value = 1 And buyTili = True Then            tl = 120 * cishu            tili = tili + tl            buyTili = False            Print #FileNumber, "购买体力" + Str(tl) + "点"        End If    Wend    Print #FileNumber, "通关主线次数:" + Str(n)    temp = temp + "当前等级:" + Str(dengji) + " 当前资金:" + Str(zijin) + vbCrLf    temp = temp + "通关主线次数:" + Str(n) + vbCrLfNext ishowTxt.Text = tempPrint #FileNumber, "角色等级:" + Str(dengji) + " 当前资金:" + Str(zijin)Close #FileNumberEnd SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)If KeyAscii = 8 ThenExit SubEnd IfIf KeyAscii < Asc("0") Or KeyAscii > Asc("9") ThenKeyAscii = 0MsgBox "只能输入数字"End IfEnd Sub


 

0 0