Results 1 to 6 of 6

Thread: deviding a number by 4

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    this is what I have right now:

    Code:
    Dim intnum As Integer
    Private Sub Command1_Click()
    intnum = Text1.Text
    intnum = intnum / 4
    Label1.Caption = intnum
    End Sub

    Now when I entered 2.63 into text 1, label1.caption = 0

    then I remembers that an integer is a whole number, what do I do to use desicmals?
    NXSupport - Your one-stop source for computer help

  2. #2
    Guest
    Use Single.

    Code:
    Dim intnum As Single
    
    Private Sub Command1_Click()
    
        intnum = Text1.Text
        intnum = intnum / 4
        Label1.Caption = intnum
        
    End Sub

  3. #3
    Member
    Join Date
    Jul 2000
    Location
    Eastern Universe
    Posts
    32
    u must not declare 'ur receiving var to integer otherwise
    decimals would be discarded...
    -----------------------------------------

    oooO Knock! Knock! Ooooo

    -----------------------------------------

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    thanks
    NXSupport - Your one-stop source for computer help

  5. #5
    Guest
    That's because VB will dynamically convert it into a Double. Declaring it as a Single at design time, will save memory.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    ok, thanks
    NXSupport - Your one-stop source for computer help

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