Results 1 to 14 of 14

Thread: [RESOLVED]DiceRoller Function

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2010
    Posts
    6

    [RESOLVED]DiceRoller Function

    Hey all,

    I have a function as such:

    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
    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?

    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.
    Last edited by Reichvier; Oct 16th, 2010 at 02:26 PM. Reason: Clarity/detail

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width