CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2014
    Posts
    26

    Integers. Should I dim my variables as integers?

    I was just wandering. When I have vb6 do mathematical calculations, should I dim my variables as integers or do I not dim them. It works both ways but I was just wandering.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Integers. Should I dim my variables as integers?

    only for WHOLE numbers between -32K and 32K
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Aug 2014
    Posts
    26

    Re: Integers. Should I dim my variables as integers?

    Thank you!

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Integers. Should I dim my variables as integers?

    Actually Long is a bit faster I think and can hold larger values than an Integer can up to 2 billion as opposed to 32k for an Int. Long does use more memory but is processed faster on 32 bit systems and I assume also on 64 bit systems

    If you need to work with numbers that may have decimal places then those would need to be either Currency, Single or Double. Using Integer or Long will cause rounding.

    You should look in the online help at the various data types to determine which is best for your needs.
    Always use [code][/code] tags when posting code.

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

Featured