try this:avoid using GoTo like the plagueCode:Option Explicit Dim intNext As Long Private Sub Command1_Click() Dim I As Long, dblSum As Double Dim strWar As String Dim bOK As Boolean ' you should have some error handling here, ' but i'll leave that for you to do intNext = CLng(Text2.Text) For I = 0 To intNext bOK = False Do Until bOK strWar = InputBox("Added " & I + 1 & " value", "Adding sections") If StrPtr(strWar) = 0 Then ' Cancel Pressed If dblSum > 0 Then If MsgBox("Do you want to Quit?", vbYesNo _ Or vbQuestion, "Question") = vbYes Then Exit Sub Else Exit Sub End If Else ' Ok Pressed If Not IsNumeric(strWar) Then MsgBox "Enter a correct value!", vbCritical Else dblSum = dblSum + CDbl(strWar) bOK = True End If End If Loop Next I MsgBox dblSum End Sub




Reply With Quote