Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, _
                           ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i, N As Integer
        Dim sum As Long = 0
        i = 1
        N = InputBox("計算 1 + 2 + ... + N = ?" + vbCrLf + "請輸入N值：")
        While i < N
            sum += i
            i += 1
        End While
        MsgBox("計算1 + 2 + ... + " & N & " = " & sum)
    End Sub
End Class
