单次测试执行doUntilLoop 就好 所有的打印日志被注释了,如果想看去掉即可。



Dim spro%, starn%, toplimt%, goldtotal%, roundtotal%
Dim totalnum%
Dim tgoldtotal&, troundtotal&
Sub doUntilLoop()
starn = 0
toplimt = 10
goldtotal = 0
roundtotal = 0
Do Until starn = 10
roundtotal = roundtotal + 1
'Debug.Print ("第" & roundtotal & "次强化,当前强化上限为" & toplimt & "当前武器星级为" & starn)
If starn = toplimt Then
goldtotal = goldtotal + 1
toplimt = toplimt + 1
'Debug.Print ("购买上限,当前已消费" & goldtotal & "0W" & Chr(10) & "当前强化上限为" & toplimt & "当前武器星级为" & starn)
End If
protmp = Application.VLookup(starn, ThisWorkbook.Sheets("Sheet1").Columns("a:b"), 2, 0) * 100
rndresult = Int(100 * Rnd + 1)
If rndresult <= protmp Then
starn = starn + 1
'Debug.Print ("合成成功")
Else
'Debug.Print ("合成失败")
starn = starn - 1
toplimt = toplimt - 1
starn = Application.WorksheetFunction.Max(0, starn)
End If
'Debug.Print ("当前成功率为" & protmp & "%,随机结果为" & rndresult & "升级结果为强化上限" & toplimt & "武器星级为" & starn)
'Debug.Print ("===================================================")
Loop
Debug.Print (roundtotal & "===" & goldtotal)
troundtotal = troundtotal + roundtotal
tgoldtotal = tgoldtotal + goldtotal
End Sub
Sub test()
tgoldtotal = 0
troundtotal = 0
For i = 1 To 10000
doUntilLoop
Next
troundtotal = troundtotal / 10000
tgoldtotal = tgoldtotal / 10000
MsgBox (troundtotal & "颗===" & tgoldtotal & "0W")
End Sub