Private Sub Form_Click()
Dim N As Integer, I As Integer, SUM As Long
N = InputBox("输入N:")
For I = 0 To N
SUM = SUM + 2 ^ I
Next I
Print SUM
End Sub
有简单的方法,就一句话:
Private Sub Form_Load()
MsgBox "结果是:" & 2 ^ Val(InputBox("输入一个正整数作为n的值:")) - 1 & "。"
End Sub
密密麻麻