Put two textboxes on your form. The first box asks users to enter a start position for a For Loop; the second textbox asks user to enter an end position for the For loop. When a button is clicked, the programme will add up the numbers between the start position and the end position. Display the answer in a message box. You can use this For Loop code
For i = startNumber To endNumber
answer = answer + i
Next i
Get the startNumber and endNumber from the textboxes.
我是这样编写的:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim startnumber As Integer
Dim endnumber As Integer