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

## All 2 Replies

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.

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``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.