Results 1 to 2 of 2

Thread: Stumped! Rounding Problem!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    160

    Question Stumped! Rounding Problem!

    This simple problem has gotten me stuck. I don't remember how to solve this!


    I'm taking one number from a text box on another form and dividing that number
    by the number of the current form and displaying the result in a textbox on the current
    form. The problem is that I'm getting like .345 and I need/require to have numbers
    starting with 1 ( whole numbers? ) ! With the data I have .### isn't a valid result it should be 1.

    How do I fix this problem?

    Thanks



    VB Code:
    1. Text7.Text = (Val(Form19.Text1(0).Text) / Val(Text1(0).Text))

  2. #2
    Lively Member L0phtpDK's Avatar
    Join Date
    Mar 2001
    Location
    ILL
    Posts
    109
    try this:
    Code:
    Text7.Text = Round(Val(Form19.Text1(0).Text) / Val(Text1(0).Text)), 0)
    that should help you... but it will say that .345 = 0 though....
    if u want so that its rounds up... go like this:
    Code:
    Dim intVal1 As Integer
    Dim intVal2 As Integer
    
    intVal1 = Round(Val(Form19.Text1(0).Text) / Val(Text1(0).Text)), 0)
    intVal2 = Val(Form19.Text1(0).Text) / Val(Text1(0).Text)
    
    If intVal1 < intVal2 Then
         Text7.text = intVal1 + 1
    Else
        Text7.Text = intVal1
    EndIf
    That code will make .345 = 1
    I have no real reason to put anything here....

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