+ Reply to Thread
Results 1 to 5 of 5

Thread: Code for dividing whole number with decimal

  1. #1
    Registered User
    Join Date
    04-13-2009
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    94

    Code for dividing whole number with decimal

    what code to use if incase i want to divide a number from textbox1 to textbox2.

    textbox1 = 10
    textbox2 = 0.02
    textbox3 = textbox1 / textbox2

    i did my own code but it gives error about "cannot divide by zero"

    thanks in advance
    Last edited by macky1730; 10-02-2010 at 10:21 AM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    MSO2007 on WinXP/MSO2000 on Win7/winXP
    Posts
    2,172

    Re: Code for dividing whole number with decimal

    Quote Originally Posted by macky1730 View Post
    i did my own code but....
    BUT! You didn't provide us with it
    Did you dimension the variables as Integer, perhaps? If so, then try DIM'ing as Single or Double.
    ---
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    04-13-2009
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    94

    Re: Code for dividing whole number with decimal

    Quote Originally Posted by protonLeah View Post
    BUT! You didn't provide us with it
    Did you dimension the variables as Integer, perhaps? If so, then try DIM'ing as Single or Double.
    i did not use DIM
    kindly show me how to use single or double. thanks

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    MSO2007 on WinXP/MSO2000 on Win7/winXP
    Posts
    2,172

    Re: Code for dividing whole number with decimal

    Please post your code, and remember to use code tags.
    Anyway, DIM is used to declare variables and is used at the beginning of your code modlule. for example:

    Sub Test()
        Dim MyVar as Single
        Dim MyOtherVar as Double
    
        MyVar=textbox1.value
    End Sub
    --


    Note that Integer variables can only hold whole numbers ranging in value from -32,768 to 32,767
    Longs hold whole numbers from -2,147,483,648 to 2,147,483,647
    Singles hold decimal valued numbers with as many as 38 to 45 decimal positions
    Double type numbers can have several hundred decimal places
    ---
    Ben Van Johnson

  5. #5
    Registered User
    Join Date
    04-13-2009
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    94

    Re: Code for dividing whole number with decimal

    Quote Originally Posted by protonLeah View Post
    Please post your code, and remember to use code tags.
    Anyway, DIM is used to declare variables and is used at the beginning of your code modlule. for example:

    Sub Test()
        Dim MyVar as Single
        Dim MyOtherVar as Double
    
        MyVar=textbox1.value
    End Sub
    --


    Note that Integer variables can only hold whole numbers ranging in value from -32,768 to 32,767
    Longs hold whole numbers from -2,147,483,648 to 2,147,483,647
    Singles hold decimal valued numbers with as many as 38 to 45 decimal positions
    Double type numbers can have several hundred decimal places
    thanks, also for the clear info
    rep added

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0