Results 1 to 3 of 3

Thread: Overflow error ... Resolved

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2002
    Location
    Tennessee
    Posts
    378

    Question Overflow error ... Resolved

    Hello,
    Can somebody tell me why I get a Run-time Overflow error on this code?


    Option Explicit
    Option Compare Text

    Dim Units As String
    Dim UnitNum As Integer 'How many units to convert from text1
    Dim EqualsNum As Integer 'Equals Box

    Dim AcreFeetFactor As Double 'Error occurs when this one is used.
    Dim AcreYardFactor As Double
    Dim AcreMeterFactor As Double
    ________________________________________________


    Private Sub ConvertButton_Click()
    If Units = "Acre" Then
    UnitNum = Text1
    AcreMeterFactor = 4.047
    AcreFeetFactor = 43560 'The error occurs when this one is used.
    AcreYardFactor = 4840

    If ComboToUS.Text = "square feet" Then
    EqualsNum = AcreFeetFactor * UnitNum
    End If
    If ComboToUS.Text = "square yards" Then
    EqualsNum = AcreYardFactor * UnitNum
    End If
    If ComboToMetric.Text = "square meters" Then
    EqualsNum = AcreMeterFactor * UnitNum
    End If
    End If
    EqualsBox = EqualsNum
    End Sub


    Run-time error 6:

    Overflow
    Last edited by GARY MICHAEL; Oct 7th, 2004 at 06:56 AM.
    Thanks,
    GARY

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    A few things:

    a) This is a Visual Basic question in an Assembly forum. To get your Visual Basic questions answered, try going here:

    http://www.vbforums.com/forumdisplay.php?s=&forumid=1

    b) Secondly, you should probably try this:
    VB Code:
    1. If Units = "Acre" Then
    2. [b]UnitNum = CDbl(Text1.Text)[/b]
    3. AcreMeterFactor = 4.047
    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2002
    Location
    Tennessee
    Posts
    378
    Thanks phReAk,

    for directing me to the right forum. I did resubmit on the VB forum.

    I made the change in code, but I still get that error.
    Thanks,
    GARY

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