| 发表于:2007-02-22 17:22:28 楼主 |
春节放假,闲着没事,静下心来,看看vb,做了几个练习题,感觉还可以,请大家看看写怎么样? 练习1:编写一个程序,使用函数方式求s=1+(1+2)+(1+2+3)+...+(1+2+3+...+n)的值 源代码如下: function sum(n as integer) dim a, j, c as integer c = 0 a = 0: j = 1 for i = 1 to n a = a + j c = a + c j = j + 1 next sum = c end function private sub command1_click() dim x as integer dim y as string y = text1.text x = val(right(y, 2)) x = sum(x) text2.text = x end sub 希望大家提提意见,向同志们学习一下 |
|
|
|
|