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() Dim n!
n = InputBox(\输入一个实数\
Print n; \的数字之和为\End Sub
Function shuzihe(x!) Dim c$, s% c = Str(x)
For i = 1 To Len(c) k = Mid(c, i, 1)
If k >= \ Next i
shuzihe = s End Function 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 = InputBox(\输入任意字符串\Print n; \中的数字个数为\End Sub
Function szgs(x)
For i = 1 To Len(x) k = Mid(x, i, 1)
If k >= \ Next i szgs = s End Function VERSION 5.00
Begin VB.Form Form1
AutoRedraw = -1 'True Caption = \ ClientHeight = 3555 ClientLeft = 60 ClientTop = 450 ClientWidth = 5760 LinkTopic = \ ScaleHeight = 3555 ScaleWidth = 5760
StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = \ Height = 495 Left = 3600 TabIndex = 0 Top = 2280 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 m%, n%
m = InputBox(\输入第一个数\n = InputBox(\输入第二个数\Print m, n
If m < n Then t = m: m = n: n = t gysgbs m, n, p
Print \最大公约数为\Print \最小公倍数为\End Sub
Public Sub gysgbs(a, b, c) Dim r As Integer c = a * b r = a Mod b Do While r <> 0 a = b b = r
r = a Mod b Loop
c = c / b End Sub
实验一 实验一 实验10
\\\\\\\\\\VERSION 5.00
Begin VB.Form Form1
Caption = \ ClientHeight = 3090 ClientLeft = 60 ClientTop = 450
ClientWidth = 4680 LinkTopic = \ ScaleHeight = 3090 ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省 End
Attribute VB_Name = \
Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False
Private Sub Form_Click()
Open \ Do While Not EOF(1)
Input #1, X1$, X2$, x3%, x4%, x5% pingjun = (x3 + x4 + x5) / 3 Print Format(pingjun, \ Loop Close End Sub
第三题需用到“定义记录类型的变量”和“随机文件的读写”等知识,超出了讲授范围,如有兴趣,可参看课本例10.6 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 = 735 Left = 3000 TabIndex = 0 Top = 2040 Width = 1575 End
End
Attribute VB_Name = \
Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub form_Click()
Open \Open \Write #1, \文件1\Write #2, \文件2\Close End Sub
Private Sub Command1_Click() Dim char$
Open \Open \Do While Not EOF(2) Line Input #2, char Print #1, char Loop Close End Sub