VB程序设计里的题目求详细编程,谢谢! 5

 我来答
chinaboyzyq
2018-06-20 · TA获得超过1.3万个赞
知道大有可为答主
回答量:1.3万
采纳率:89%
帮助的人:3256万
展开全部
Private Sub Command1_Click()
Dim a As Single, b As Long
Dim n As Long, f As Integer
Dim c As Single

f = 1
For n = 1 To Val(Text1.Text)
  b = b * 10 + 3
  a = b + 0.3
  c = c + a * f
  f = -f
Next
Label2.Caption = c

End Sub

Private Sub Form_Load()
Label1.Caption = "3.3-33.3+333.3-3333.3+...="
End Sub
Yuqi_Tan

2018-06-22 · TA获得超过8.9万个赞
知道大有可为答主
回答量:9918
采纳率:93%
帮助的人:3454万
展开全部
你只要在窗口中放一个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
已经运行过。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式