2009年1月21日 星期三

廬山99-7 : 計算 1 + 2 + ... + n = ﹖




Public Class Form1
Dim n, i, s
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
n = Val(TextBox1.Text)
For i = 1 To n
s = s + i
Next
TextBox2.Text = s
End Sub
End Class

1 則留言:

  1. Public Class Form1
    Dim n, i, s
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     n = Val(TextBox1.Text)
     For i = 1 To n
      s = s + i
     Next
     TextBox2.Text = s
    End Sub

    程式稍做縮排,看起來比較舒服。
    End Class

    回覆刪除