0

Hi,
i have got code:

Dim numbers(99) As String
Dim howmany As String

Private Sub Command1_Click()
howmany = InputBox("how many number you want input?")

For x = 1 To howmany

    numbers(x) = InputBox("Enter a number")
    
Next x

FontSize = 14

For y = 1 To howmany

Print numbers(y)

Next y

End Sub

Private Sub Command2_Click()

For x = 1 To howmany
Set total = total + numbers(x)

Print total
Next x

End Sub

and now i would like to add total numbers printed after clicking Command2_click button, can someone help me?
I would like to print or display answer in msgbox

Edited by pytup: n/a

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by QVeen72
0

Hi,

Hi Change your Command2_click code like this :

Private Sub Command2_Click() For x = 1 To howmanySet total = total + numbers(x) Print totalNext x End SubDim numbers(99) As String
Dim howmany As String

Private Sub Command1_Click()
howmany = InputBox("how many number you want input?")

For x = 1 To howmany

    numbers(x) = InputBox("Enter a number")
    
Next x

FontSize = 14

For y = 1 To howmany

Print numbers(y)

Next y

End Sub

Private Sub Command2_Click()
Dim x As Integer
Dim MyTotal as Double
MyTotal = 0
For x = 1 To howmany
    MyTotal = MyTotal + numbers(x)
Next x
Print "Total Is : " & MyTotal
Msgbox "Total Of All the Entered Numbers Is : " & MyTotal
End Sub

Regards
Veena

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.