设窗体上text1为输入文本框, text2为结果文本框,, cmd1为计算按钮, cmd2为清空按钮,则
private sub cmd2_click()
text1.value=""
text2.value=""
text1.setfocus
end sub
private sub cmd1_click()
dim I as integer, N as integer, R as integer
N = text1.value
for I = 1 to N
R =R+((I mod 2)*2-1)*I
next
text2.value = R
end sub