access VBA编程语言

2024-10-30 20:47:11
推荐回答(1个)
回答1:

设窗体上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