0

I am kinda new to Visual Basic and I was wondering how I could program a user to input 3 numbers and give the sum, average, product, and find the smallest and largest number using a Windows Application

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Jx_Man
0

make three textbox for input.
- to get sum u just add all textbox value
ex. sum = val(textbox1.text) + val(textbox2.text) + ...
- average = sum / 3
- to display you can use label or message box, or textbox.

0

see this example :

Private Sub Command1_Click()
Sum.Caption = "Sum : " & (Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text))
Average.Caption = "Average : " & ((Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text)) / 3)

If Val(Text1.Text) < Val(Text2.Text) And Val(Text1.Text) < Val(Text3.Text) Then
    Smallest.Caption = "Smallest : " & Text1.Text
ElseIf Val(Text2.Text) < Val(Text1.Text) And Val(Text2.Text) < Val(Text3.Text) Then
    Smallest.Caption = "Smallest : " & Text2.Text
ElseIf Val(Text3.Text) < Val(Text1.Text) And Val(Text3.Text) < Val(Text1.Text) Then
    Smallest.Caption = "Smallest : " & Text3.Text
End If

If Val(Text1.Text) > Val(Text2.Text) And Val(Text1.Text) > Val(Text3.Text) Then
    Larger.Caption = "Larger : " & Text1.Text
ElseIf Val(Text2.Text) > Val(Text1.Text) And Val(Text2.Text) > Val(Text3.Text) Then
    Larger.Caption = "Larger : " & Text2.Text
ElseIf Val(Text3.Text) > Val(Text1.Text) And Val(Text3.Text) > Val(Text1.Text) Then
    Larger.Caption = "Larger : " & Text3.Text
End If

End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.