Consulting

Results 1 to 3 of 3

Thread: Solved: Division with remainder

  1. #1
    VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location

    Solved: Division with remainder

    Using the following code (straight VB) how would you change is to make the txtAnswer.Text text box read for instance "4 remainder 7" rounding it up or down depending.

    [VBA]
    If
    chkDivide.Checked = TrueThen
    decAnswer = decFirstInputNumber / decSecondInputNumber
    txtCalcFirstNumber.Text = txtFirstNumber.Text
    txtCalcSecondNumber.Text = txtSecondNumber.Text
    txtOperator.Text = (
    "/")
    txtAnswer.Text = decAnswer.ToString
    EndIf
    [/VBA]
    Peace of mind is found in some of the strangest places.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    How about this

    [vba]

    If chkDivide.Checked Then
    decAnswer = decFirstInputNumber / decSecondInputNumber
    txtCalcFirstNumber.Text = txtFirstNumber.Text
    txtCalcSecondNumber.Text = txtSecondNumber.Text
    txtOperator.Text = ("/")
    txtAnswer.Text = (decFirstInputNumber \ decSecondInputNumber) & _
    " remainder " & _
    (decFirstInputNumber Mod decSecondInputNumber)
    End If
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Spot on as usual Bob. Thanks
    Peace of mind is found in some of the strangest places.

Posting Permissions

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