accessvba编程正等腰三角的简单介绍
VBA编程 access
设窗体上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 'I除2的余数为0或1,将其×2后为0或2,-1后为-1或1
next
text2.value = R
end sub
vba编程怎么用for next 循环输出数字正三角形? 如 1 2 3 4 5 6
你可以试下下面的代码,在 j1 单元格输入你想的层数,点击按钮执行下面的代码,看符合你的要求吗
Sub 正三角数()
Dim r%, c%, suo%, a
If Cells(1, 10) = "" Then
MsgBox "请在j1单元输入你希望得到的层数", 48, "提示"
Exit Sub
End If
a = 1
suo = Cells(1, 10)
For r = 1 To suo
For c = 1 To r
Cells(r, c) = a
a = a + 1
Next c, r
End Sub
Access的VBA编程问题,在线等
“计算”按钮的_onclick事件程序
With Me
If Not IsNull(.Tt1.Value) Then
If IsNumeric(.Tt1.Value) Then
If Not IsNull(.Tt2.Value) Then
If IsNumeric(.Tt2.Value) Then
.Tt3.Value = Val(.Tt1.Value) + Val(.Tt2.Value)
End If
End If
End If
End If
End With
“关闭”按钮的_onclick事件程序
docmd.close acform, me.name, acsaveyes