Program in visual basic to calculate the sum of the elements of array.

Option Base 1
Dim a() As Integer
Dim i As Integer
Dim sum, s As Integer
Private Sub Command1_Click()
s = Val(Text1.Text)
ReDim a(s) As Integer
sum = 0
For i = 1 To s
a(i) = InputBox("enter the value")
sum = sum + a(i)
Next i
Text2.Text = sum
End Sub

No comments:

Post a Comment