一道vb题1!-2!···

题目:(事件)单击窗体。
(响应)已知sum=1!-2!+3!-4!···-10!
将sum结果值输出到窗体上。
实用do while···loop语句完成程序
答对我会增加财富值的!!谢谢

Private Sub Form_Click()
Dim sum As Integer, a As Integer, fact As Integer
a = 1
sum = 1
fact=a
Do While a <10
a=a+1
fact=fact*a
sum=sum+(-1)^(a-1)*fact
Loop
Print "计算结果是:" ; sum
End Sub

Ps:这应该自己想一下的,这不算难,几句就可搞定来自:求助得到的回答
温馨提示:内容为网友见解,仅供参考
第1个回答  2012-12-30
Private Sub Form_Click()
Dim j As Double, sum As Double, n As Integer, fh as integer
j = 1
n = 1
fh = 1 '控制符号,第一为1 ,n=2时为-1
Do While n <= 10
j = j * n
sum = sum + j * fh
fh = - fh
n = n + 1
Loop
Print sum
End Sub本回答被网友采纳
第2个回答  2012-12-30
Private Sub Form_Click()
Dim jc As Double, sum As Double, n As Integer
jc = 1
n = 1
Do While n <= 10
jc = jc * n
sum = sum + jc
n = n + 1
Loop
Print sum
End Sub
第3个回答  2012-12-30
Private Sub Form_Click()
Dim j As Double, sum As Double, n As Integer, k as integer
j = 1
n = 1
k = 1
Do While n <= 10
j = j * n
sum = sum + j * k
k = - k
n = n + 1
Loop
Print sum
End Sub

用VB编程计算:1!-2!+3!-4!+…-10! 这个代码是什么?
1!-2!+3!-4!+…-10!=1-2*1+3*2*1-4*3*2*1+…-10*9*8*7*6*5*4*3*2*1=?看到规律没?用两个嵌套的for for i=1 to 10 s=0 for j=1 to i s=s*j*(-1)^(i+1)end for t=t+s end for ? t

vb中sum=1!-2!+3!……-10!编程
Private Sub Command1_Click()Dim j As Integer, k As IntegerDim sum As Long, jc As Long, fh As Integerjc = 1: fh = 1For j = 1 To 10 For k = 1 To j jc = jc * k Next sum = sum + jc * fh fh = -fh jc = 1NextMsgBox sumEnd Sub ...

vb编程 已知sum=1!-2!+3!-4!...-10!,请将sum值输出到窗体上 用do while...
Private Sub Form_Load()Dim i As Integer, n As Long Dim k As Long i = 1: n = 1 Do While i <= 10 n = n * i k = k + (-1) ^ (i - 1) * n i = i + 1 Loop Print k End Sub 结果:-3301819

vb编写,计算1-2+3-4+5……+99-100
sum=0 for i=1 to 100 sum=sum+i*j j=-j next msgbox "和为" & sum

vb试题编程计算1-1\/2+1\/3-1\/4+...+1\/99-1\/100的四种方法是什么?
1:\\x0d\\x0aDim i As Integer\\x0d\\x0aDim s As Double\\x0d\\x0aDim s0 As Double\\x0d\\x0aFor i = 1 To 100\\x0d\\x0as0 = 1 \/ i\\x0d\\x0aIf i Mod 2 = 0 Then s0 = s0 * (-1)\\x0d\\x0as = s + s0\\x0d\\x0aNext\\x0d\\x0aPrint s\\x0d\\x0a\\x0d\\...

VB题,为什么这题选-1
这个表达式里的等号是关系运算符号,是判断该等号两边的值是否相等;若该等号两边的值相等,表达式的结果就为True,若该等号两边的值不等,表达式的结果就为False。因为本题 y = -2,所以表达式y = -2的结果是True,而因为变量X定义为整型,在VB里规定当把True保存到整型变量的时候,自动转换为-1;...

一道Vb基础题选择题
一、选择题 (1)下列叙述中正确的是 A)程序设计就是编制程序 B)程序的测试必须由程序员自己去完成 C)程序经调试改错后还应进行再测试 D)程序经调试改错后不必进行再测试 (2)下列数据结构中,能用二分法进行查找的是 A)顺序存储的有序线性表 B)线性链表 C)二叉链表 D)有序线性链表 (3...

求VB程序代码 1!+2!……20!的和
1 To 20 Multiply MDigit, i If UBound(MDigit) > UBound(Sum) Then ReDim Preserve Sum(UBound(MDigit))End If Add Sum, MDigit Next Dim result As String For i = UBound(Sum) To 0 Step -1 result = result & Sum(i)Next MsgBox result End Sub 最后结果是:2561327494111820313 ...

怎样用VB编写过程,计算1!+2!+3!+。。。+N!,N值由用户输入
楼上的好像错了,做了小改动!如下:Private Sub Command1_Click()Dim i As Integer Dim n As Integer Dim ans as integer Dim y As Integer=1 n = InputBox("请输入一个正整数: ")y=1 ans=0 For i = 1 To n y = y * i ans=ans+y Next i Print ans End Sub ...

VB编程 计算1!+2!+…5!
第一种(对比计算PrivateSubCommand1_Click()Timer1.Enabled=TrueTimer1.Interval=1'计算一次用时量EndSubPrivateSubForm_Load()Text2.Text="0"'计算方法初始化Text3.Text="0"'计算开始初始化Text4.Text="1"'次数计算初始化EndSubPrivateSubTimer1_Timer()DimaAsInteger,bAsStringIfVal(Text4.Text)<...

相似回答