Microsoft Visual basics runtime error "6"-Overflow

Anonymous
2020-08-20T16:36:08+00:00

I am using Microsoft visual basics 6.0 on windows 8.1. And I have created a form for addition and subtraction. I am a school student, and due to lockdown, I can also not ask my doubt from the teacher. So, I am posting this question here and hope it is cleared faster as my IT examinations are close. In fact, this Monday only. When I try this form, it shows an error like this if I enter more than five numbers. 

Please help me with this its urgent!!!! Let me also share you my code: -

Private Sub Command1_Click()

Dim num1, num2 As Integer

num1 = Val(Text1.Text)

num2 = Val(Text2.Text)

um = (num1 + num2)

Text3.Text = um

End Sub

Private Sub Command2_Click()

Dim num1, num2 As Integer

num1 = Val(Text1.Text)

num2 = Val(Text2.Text)

difference = (num1 - num2)

Text3.Text = difference

End Sub

Private Sub Command3_Click()

End

End Sub

I am also sharing my form: -

Please help me fast!!!!! Please!!!!!!

Microsoft 365 and Office | Install, redeem, activate | For home | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    2020-08-20T17:24:09+00:00

    Hello,

    Thank you for reaching out. I am Harun an Independent Advisor and Microsoft User. I will gladly help you out.

    I might have become a bit rusty on this yet I would recommend to define

    um and difference as integer or Long before I assign the main value to them and see what will come out.

    Dim num1, num2, um As Integer

    Dim num1, num2, difference As Integer

    or

    Dim um As Long

    Dim difference As Long

    Please feel free to ask for more Information and let me know if this helps.

    Sincerely

    Independent Advisor

    Harun

    0 comments No comments
  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more