关于计算1/(1!+(1!+3!)+(1!+3!+5!)+….+(1!+3!+….+n!))的值?
在窗体上有一个text控件,一个command控件
有下面这样一段程序
Option Explicit
Private Sub Command1_Click()
Dim intA As Long
Dim intB As Long
Dim intS As Long
Dim intI As Integer
Dim n As Integer
Dim varT As Variant
Do
n = Val(InputBox(“输入一个(1~11)之间的奇数:”))
Loop
intA = 1
intB = 1
intS = 0
varT = 0
For intI = 1 To n
intA = intB * intI
intB =
intS = intS + intA
varT = varT + intS
Next K
varT = 1 / varT
Text1.Text = varT
End Sub
着段程序应该怎么改动才能实现这个功能啊 ?的问题
你原代码的错误楼上都说的很对,但修正这些语法错误,执行结果不对。以下是解决问题的代码:
Option Explicit
Private n1 As Long
Private a As Double
Private b As Long
Private aa(20) As Double
Private bb(20) As Double
Private i As Double
Private j As Long
Private n As Long
Private p As Double
Private Sub Command1_Click()
n1 = Val(Text4)
For i = 1 To n1 Step 2
n = n1
a = 1
b = 0
Call js
bb(i) = 0
p = 0
For j = 1 To n
If Int((j + 1) / 2) – (j + 1) / 2 = 0 Then
bb(j) = bb(j) + aa(j) ‘ – (j – 1) * 1
p = p + bb(j)
Text2 = p
Text3 = 1 / p
End If
Next j
Next i
If n1 = Text1 Then
Timer1。
Enabled = False
Command1。Enabled = False
Else
Text4 = n1 + 2
Timer1。Enabled = True
End If
End Sub
Private Sub Form_Load()
Text3 = “”: Text4 = 1: Text1 = “”: Text2 = “”
End Sub
Private Function js()
For i = 1 To n
a = a * i
aa(i) = a
Next i
End Function
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Val(Text1)
SetFocus
End If
End Sub
Private Sub Timer1_Timer()
Call Command1_Click
End Sub
压缩的工程文件附后上传。
。