Hey all,
I have a function as such:
I'm sending the function a user determined value from another section. My problem is, it only seems to be generating one number, and listing each roll as a hit. How can I get a new roll(repeating values are fine) for each loop iteration?Code:Function THRoller(ByVal Swings As Integer) As Integer Dim Hits, Misses As Integer 'variables for attack results Do Until RollCount = 0 'RollCount taken from initiative winners AttacksBox THRollVal = CInt(Int((6 * Rnd()) + 1)) If THRollVal >= THN Then 'if the roll is greater or equal to the to hit number, it hits Hits = Hits + 1 RollCount = RollCount - 1 ElseIf THRollVal < THN Then 'if the roll is less than the to hit number, it misses Misses = Misses + 1 RollCount = RollCount - 1 End If Loop MsgBox("Rollcount is " & RollCount & "and hits equal " & Hits) 'why do you keep showing me one number??? End Function
My apologies if the answer is obvious. I've only been programming for a week or so. Any other tips for cleaner/faster practices would be appreciated as well.




Reply With Quote