2个回答
展开全部
你只要在窗口中放一个frame,再在frame中放两个label1和label2。再在frame外面放一个label3,一个command1,一个text1。其他由程序完成,程序如下,已经运行过:
Private Sub Command1_Click()
Dim Sum As String
Dim N As Integer
Dim I As Integer, J As Integer, K As Integer
Dim S As Integer
N = Val(Text1)
For I = 1 To N
If I = 1 And (N Mod 2 = 0) Then K = -1 Else K = 1
S = 0
For J = 1 To I
S = S + K
K = -K
Next
Sum = Sum & S
Next
If Right(Sum, 1) = "1" Then Sum = Sum & ".1"
For I = 1 To Len(Sum)
If Mid(Sum, I, 1) = "1" Then Mid(Sum, I, 1) = "3"
Next
Label2.Caption = Sum
End Sub
Private Sub Form_Load()
With Form1
.Caption = "求和计算"
.Width = 7000
.Height = 4000
End With
With Frame1
.Caption = "求数列前N项和"
.Width = 6000
.Height = 1000
.Top = 500
.Left = 500
End With
With Label1
.Width = 2500
.Height = 500
.Caption = "3.3-33.3+333.3-3333.3+...="
.Top = 400
.Left = 100
End With
With Label2
.Width = Frame1.Width - (Label1.Left + Label1.Width) - 100
.Height = Label1.Height
.Caption = ""
.Top = 400
.Left = Label1.Left + Label1.Width
End With
With Text1
.Width = 1000
.Height = 300
.Text = ""
.Top = 2500
.Left = 4000
End With
With Command1
.Caption = "计算"
.Width = 1000
.Height = 300
.Top = 2500
.Left = 1000
End With
With Label3
.Width = 2000
.Height = Label1.Height
.Caption = "输入N的值,N="
.Top = Command1.Top
.Left = Command1.Left + Command1.Width + 500
End With
End Sub
2018-06-20 · 知道合伙人互联网行家
关注
展开全部
先用一个过程private function mulitiply ( byval n as integer) as integermulitply = 10do while n >0mulitply = mulitply * nn = n-1loopend function 再写事件代码由窗体的单击事件触发。dim sum ,idim se as stringsum = sum + mulitply (i)se = msgbox(“计算的结果是”,sum)上面写的是1到10的阶乘 可以随便该下
追问
可不可以详细点
谢谢
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询