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

    Over Flow Error !!!

    hi all,
    I am facing an unusual error.

    I've declared a loopCount variable as double
    inside a do.. loop until block i'm incrementing this counter by 1.
    loopcount = loopcount + 1

    If i don't put an end it will loopCount can hold more than 436500 (may run still further but i stopped there !!)

    But if i try to put an end to loop by evaluating like this

    dim ipass as integer
    ipass = 36
    if loopcount >= (ipass*1500)

    it says ' OVERFLOW'

    why it is happening so..

    now i really became new to vb ;-(

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

    Re: Over Flow Error !!!

    Tell VB that 1500 isn't a Variant. Make it a Long &
    Code:
    Option Explicit
    
    Private Sub Form_Activate()
    Dim ipass As Integer
    ipass = 36
    MsgBox (ipass * 1500&)
    End Sub
    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
    Mar 2006
    Posts
    47

    Resolved Re: Over Flow Error !!!

    Quote Originally Posted by dglienna
    Tell VB that 1500 isn't a Variant. Make it a Long &
    Code:
    Option Explicit
    
    Private Sub Form_Activate()
    Dim ipass As Integer
    ipass = 36
    MsgBox (ipass * 1500&)
    End Sub
    Thanks dglienna, Thats was the simple way of understanding simple things...( ones we know the answer everything becoms simple..)

    Thanks a lot..

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

    Re: Over Flow Error !!!

    I wish someone would have answered my question quicker a few years ago. I had the same problem, and ended up changing a lot of code before I found the answer.
    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!

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