用VB编写函数过程,计算s=1+1\/2+1\/3+…+1\/100。运行程序时,单击窗体...
private sub Form_Click()dim i as long dim s as currency s=1 for i=2 to 100 s=s+(1\/i)next i msgbox s end sub '这个程序会弹出精确到4位小数的结果,如果需要更高精度的,可以试着把currency换成double。
VB编程题:1+1\/2+1\/3+...+1\/100=?用函数调用的方法
Option Explicit Private Sub Command1_Click()Print MyJ(100)End Sub Private Function MyJ(ByVal J As Integer) As Double Dim i As Integer Dim JJ As Double JJ = 0 For i = 1 To J JJ = JJ + 1 \/ i Next i MyJ = JJ End Function ...
求用VB写出关于1+2+3+…+100累加和的代码
编写函数:Private Function S_GS(S_From As Long, S_To As Long) As Long If S_From > S_To Then Exit Function S_GS = (S_From + S_To) * (S_To - S_From + 1) \/ 2 End Function 调用:S_GS("第一个数值","累加至的数值")比如:计算从1加到100。表达:S_GS(1,100)...
编写一个vb程序计算1\/1!+1\/2!+…+1\/n!,要求定义一个函数来计算n!。
回答:function jiecheng(s) m=1 n=1 if s=1 then jiecheng=1 else for i=2 to s n=(i-1)*i m=m+1\/n end for jiecheng=m end if end function 大概是这样的,很久没用过VB了,所以具体的一些细节记不清楚了
编程计算1+X+X^2+...+X^n的子过程和函数过程,并分别调用,其中X和n的...
d=inputbox("输入N")x=inputbox("输入X")msgbox mcase(d,x)function mcase(d,x)for n=1 to d if n=1 then j=x+1 else j=j+x^n end if next mcase=j end function
1\/2+1\/3+1\/3。。。+1\/N有公式吗
Select End If End Sub Private Function f2(n As Integer) As Single '计算公式1+1\/2+...+1\/n Dim i As Integer, s As Single s = 0 For i = 1 To n s = s + 1 \/ i Next i f2 = s '确定函数返回值 End Function ...
VB题:e=1+1\/1!+1\/2!+1\/3!+...+1\/n!
For iCount = 1 To N eRet = eRet + 1 \/ FunforM(iCount)Next Else MsgBox ("N小于零或非数字")Exit Sub End If MsgBox CStr(eRet)End Sub Private Function FunforM(ByVal I As Long)If (I > 1) Then FunforM = I * FunforM(I - 1)Else FunforM = 1 End If End Function ...
如何用vb的for循环语句制作1+1\/2+1\/3+1\/4+1\/5程序
Private Sub Command1_Click()Dim i As Integer Dim s As Double s = 0 N = 5 For i = 1 To N s = s + 1 \/ i Next i Print s End Sub 我写在按钮被按下的响应函数中了。N定义为5,运行结果是2.283333333333
e=1+1\/1!+1\/2!+1\/3!+...+1\/n! 求e的值,要求用vb
新建一个工程,在form1上放一个text和一个command 代码:Private Sub Command1_Click()Dim I As Integer, e As Long, n As Integer n = InputBox("输入一个自然数:", "输入提示", "")e = 1 For I = 1 To n Step 1 e = e * I Next I Text1.Text = e End Sub ...
1\/2 +1\/3 +...1\/(n+1)=
有两种方法进行计算:1、由大加到小,即1+1\/2+...+1\/n 2、由小加到大,即1\/n+1\/(n-1)+...+1 这两种方式结果有差异,在n较大时第2种方式总比第1种方式得到的结果大。具体的原因分析可以参考“数值处理”中的“误差分析”部分。下面的函数是用VB编写的,你可以测试一下。祝你好运!-...