Dim sum As Integer
Dim average As Single
Dim a, b As Single
a = Val(txtA.Text)
b = Val(txtB.Text)
sum = 0
While a <= b
sum = sum + a
lstShow.Items.Add(a)
a = a + 1
average = sum / (a - 1)
End While
lstShow.Items.Add("----------")
lstShow.Items.Add("ผลรวมทั้งหมด = " & sum)
lstShow.Items.Add("ค่าเฉลี่ย = " & average)