VisualBasic程序设计—实验报告册-参考答案 下载本文

内容发布更新时间 : 2024/5/7 8:16:49星期一 下面是文章的全部内容请认真阅读。

Next Next Next End Sub

Private Sub Command2_Click() For i = 0 To 9 For j = 0 To 9 For k = 0 To 9

If Val(i & i & k) + Val(j & k & k) = 532 Then Print i; j; k Next Next Next End Sub

VERSION 5.00

Begin VB.Form Form1

Caption = \ ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = \ ScaleHeight = 3090 ScaleWidth = 4680

StartUpPosition = 3 '窗口缺省 Begin VB.TextBox Text1 Height = 615 Left = 1200 TabIndex = 1 Top = 840 Width = 2415 End

Begin VB.CommandButton Command1 Caption = \ Height = 495 Left = 1920 TabIndex = 0 Top = 1920 Width = 1215 End End

Attribute VB_Name = \

Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() x = Val(Text1) y = x * 4 n = 0

Do While x <= y x = x * (1 + 0.1) n = n + 1 Print x Loop

Print x, n End Sub

VERSION 5.00

Begin VB.Form Form1

Caption = \ ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = \ ScaleHeight = 3090 ScaleWidth = 4680

StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = \ Height = 495 Left = 1800 TabIndex = 0 Top = 1320 Width = 1215 End End

Attribute VB_Name = \

Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click()

n = Val(InputBox(\输入计算到第几项:\For i = 1 To n

s = s + (-1) ^ (i + 1) * i

Next

Print n, s End Sub

VERSION 5.00

Begin VB.Form Form1

Caption = \ ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = \ ScaleHeight = 3090 ScaleWidth = 4680

StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command2 Caption = \双循环\ Height = 495 Left = 2520 TabIndex = 1 Top = 1680 Width = 1215 End

Begin VB.CommandButton Command1 Caption = \单循环\ Height = 495 Left = 600 TabIndex = 0 Top = 1680 Width = 1215 End End

Attribute VB_Name = \

Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim n%, s%

n = Val(InputBox(\输入计算到第几项:\s = 0: t = 0 For i = 1 To n t = t + i s = s + t Next i

Print s End Sub

Private Sub Command2_Click() Dim n%, s%

n = Val(InputBox(\输入计算到第几项:\s = 0: t = 0 For i = 1 To n t = 0

For j = 1 To i t = t + j Next

s = s + t Next Print s End Sub

VERSION 5.00

Begin VB.Form Form1

Caption = \ ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = \ ScaleHeight = 3090 ScaleWidth = 4680

StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = \ Height = 495 Left = 2160 TabIndex = 0 Top = 1920 Width = 1215 End End

Attribute VB_Name = \

Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim s As Double, pi As Double n = 1: s = 0

Do While 1 / (2 * n - 1) >= 0.0001

s = s + (-1) ^ (n + 1) * 1 / (2 * n - 1) n = n + 1 Loop

pi = 4 * s Print pi End Sub

VERSION 5.00

Begin VB.Form Form1

Caption = \ ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = \ ScaleHeight = 3090 ScaleWidth = 4680

StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = \ Height = 495 Left = 1920 TabIndex = 0 Top = 1560 Width = 1215 End End

Attribute VB_Name = \

Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() For n = 100 To 999 k = Trim(Str(n))

If n = Left(k, 1) ^ 3 + Mid(k, 2, 1) ^ 3 + Right(k, 1) ^ 3 Then Print n Next End Sub

VERSION 5.00

Begin VB.Form Form1

Caption = \ ClientHeight = 3090 ClientLeft = 60