please help me with exception handling

please help me to write the code or algorithm for this program.

Input a list of integers: 3 5 12 -2 0 -3
Sum of squares: 191

the program that i will make will go like this:

I will use a textbox then I will put integers in it. Then the integers that i will input will be squared for example, input integers; 3 9 12 and then 3 becomes 9, 9 will be 81 and 12 will be 144 after that, if i press the command button the integers 9,81, and 144 will be added or sum up.

the exception handling are:
range of -100 to 100
to the ensure that the input values are in range and are legal integers,

________________
how can i read the integers that I put in the textbox?
how can i square the integers and add it all?
how can i apply the exception handling/
to handle the error of the sum of the squares becoming larger

i hope someone would help me... Thank you =D


Comments

  • : please help me to write the code or algorithm for this program.
    :
    : Input a list of integers: 3 5 12 -2 0 -3
    : Sum of squares: 191
    :
    : the program that i will make will go like this:
    :
    : I will use a textbox then I will put integers in it. Then the
    : integers that i will input will be squared for example, input
    : integers; 3 9 12 and then 3 becomes 9, 9 will be 81 and 12 will be
    : 144 after that, if i press the command button the integers 9,81, and
    : 144 will be added or sum up.
    :
    : the exception handling are:
    : range of -100 to 100
    : to the ensure that the input values are in range and are legal
    : integers,
    :
    : ________________
    : how can i read the integers that I put in the textbox?
    : how can i square the integers and add it all?
    : how can i apply the exception handling/
    : to handle the error of the sum of the squares becoming larger
    :
    : i hope someone would help me... Thank you =D
    :
    :
    :

    Try this.
    Place 3 textbox, text1 text2 and text3
    place 1 label
    2 command buttons
    then place this on your code

    Private Sub Command1_Click()
    Dim n1 As Integer, n2 As Integer, n3 As Integer
    n1 = Val(Text1.Text)
    n2 = Val(Text2.Text)
    n3 = Val(Text3.Text)
    If n1 >= -100 And n1 <= 100 Then
    If n2 >= -100 And n2 <= 100 Then
    If n3 >= -100 And n3 <= 100 Then
    n1 = n1 * n1
    n2 = n2 * n2
    n3 = n3 * n3
    Text1.Text = n1
    Text2.Text = n2
    Text3.Text = n3
    Else
    MsgBox ("Invalid Value")
    End If
    Else
    MsgBox ("Invalid Value")
    End If
    Else
    MsgBox ("Invalid Value")
    End If
    End Sub

    Private Sub Command2_Click()
    Label1 = "= " & Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text)
    End Sub

    i hope this will help
    I'm the best there is,
    the best there was,
    and the best there ever will be.
    hahahahaha lolz :)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion