Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i, n, sum As Integer
        n = InputBox("請輸入 n 值")
        i = 1
        While i < n
            sum = sum + i
            i = i + 1
        End While
        MsgBox("1 + 2 + … + " & n & " = " & sum)
    End Sub
End Class
