首页 VB课后答案

VB课后答案

举报
开通vip

VB课后答案VB课后答案 1,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 ...

VB课后答案
VB课后答案 1,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 375 Left = 2640 TabIndex = 0 Top = 2400 Width = 1575 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Print Sqr(8), 8 ^ (1 / 3) End Sub 2,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 3720 TabIndex = 0 Top = 2640 Width = 855 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim i% For i = 100 To 110 Print i, i ^ (1 / 2) Next End Sub 3,VERSION 5.00 Begin VB.Form Form1 AutoRedraw = -1 'True Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 BeginProperty Font _GB2312" Name = "楷体 Size = 21.75 Charset = 134 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H000000FF& LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Form_Load() Print: Print Print " 郑州大学在前进~" End Sub 4,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3780 ClientLeft = 60 ClientTop = 345 ClientWidth = 6285 LinkTopic = "Form1" ScaleHeight = 3780 ScaleWidth = 6285 StartUpPosition = 3 '窗口缺省 Begin VB.Label Label1 Caption = "蓝天、白云、绿水、青山" BeginProperty Font Name = "宋体" Size = 21.75 Charset = 134 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00FF0000& Height = 975 Left = 600 TabIndex = 0 Top = 1080 Width = 4935 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False 第二章 1,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 3615 BeginProperty Font Name = "宋体" Size = 12 Charset = 134 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 3615 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command2 Caption = "商" Height = 375 Left = 1920 TabIndex = 4 Top = 1680 Width = 975 End Begin VB.CommandButton Command1 Caption = "乘积" Height = 375 Left = 600 TabIndex = 3 Top = 1680 Width = 975 End Begin VB.TextBox Text2 Height = 375 Left = 1920 TabIndex = 2 Top = 840 Width = 1095 End Begin VB.TextBox Text1 Height = 375 Left = 480 TabIndex = 1 Top = 840 Width = 1095 End Begin VB.Label Label3 BorderStyle = 1 'Fixed Single Caption = "Label3" Height = 375 Left = 2040 TabIndex = 6 Top = 2400 Width = 975 End Begin VB.Label Label2 Caption = "计算结果为:" Height = 375 Left = 480 TabIndex = 5 Top = 2400 Width = 1575 End Begin VB.Label Label1 AutoSize = -1 'True Caption = "请输入两个数:" Height = 240 Left = 960 TabIndex = 0 Top = 360 Width = 1785 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Label3 = Val(Text1) * Val(Text2) End Sub Private Sub Command2_Click() Label3 = Val(Text1) / Val(Text2) End Sub 2,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 5490 BeginProperty Font Name = "宋体" Size = 12 Charset = 134 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 5490 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command3 " Caption = "隐藏 Height = 375 Left = 4080 TabIndex = 3 Top = 2040 Width = 975 End Begin VB.CommandButton Command2 Caption = "图片2" Height = 375 Left = 4080 TabIndex = 2 Top = 1320 Width = 975 End Begin VB.CommandButton Command1 Caption = "图片1" Height = 375 Left = 4080 TabIndex = 1 Top = 600 Width = 975 End Begin VB.PictureBox Picture1 AutoSize = -1 'True BeginProperty Font Name = "宋体" Size = 9 Charset = 134 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 1935 Left = 600 ScaleHeight = 1875 ScaleWidth = 2715 TabIndex = 0 Top = 480 Width = 2775 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Picture1.Picture = LoadPicture("d:\tu1.jpg") End Sub Private Sub Command2_Click() Picture1.Picture = LoadPicture("d:\tu2.jpg") End Sub Private Sub Command3_Click() Picture1.Visible = False End Sub 3,VERSION 5.00 Begin VB.Form Form1 Caption = "收款机" ClientHeight = 2730 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 BeginProperty Font Name = "宋体" Size = 12 Charset = 134 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty LinkTopic = "Form1" ScaleHeight = 2730 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "总价为" Height = 375 Left = 600 TabIndex = 4 Top = 1920 Width = 1695 End Begin VB.TextBox Text2 Height = 495 Left = 3000 TabIndex = 3 Top = 960 Width = 1335 End Begin VB.TextBox Text1 Height = 495 Left = 3000 TabIndex = 2 Top = 240 Width = 1335 End Begin VB.Label Label3 Alignment = 2 'Center BorderStyle = 1 'Fixed Single Height = 495 Left = 2760 TabIndex = 5 Top = 1920 Width = 1455 End Begin VB.Label Label2 Alignment = 2 'Center Caption = "货物的单价(元):" Height = 375 Left = 360 TabIndex = 1 Top = 1080 Width = 2295 End Begin VB.Label Label1 Alignment = 2 'Center Caption = "货物的数量(个):" Height = 375 Left = 360 TabIndex = 0 Top = 360 Width = 2295 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Label3 = Text1 * Text2 End Sub 4, VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 1890 ClientLeft = 60 ClientTop = 450 ClientWidth = 4365 LinkTopic = "Form1" ScaleHeight = 1890 ScaleWidth = 4365 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command2 Caption = "清除" BeginProperty Font Name = "宋体" Size = 12 Charset = 134 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 2400 TabIndex = 3 Top = 1200 Width = 975 End Begin VB.CommandButton Command1 Caption = "复制" BeginProperty Font Name = "宋体" Size = 12 Charset = 134 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 720 TabIndex = 2 Top = 1200 Width = 975 End Begin VB.TextBox Text2 Height = 495 Left = 2160 TabIndex = 1 Top = 360 Width = 1695 End Begin VB.TextBox Text1 Height = 495 Left = 480 TabIndex = 0 Top = 360 Width = 1455 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Text2 = Text1 End Sub Private Sub Command2_Click() Text1 = "" Text2 = "" End Sub Private Sub Form_Load() Command1.Visible = False Command2.Visible = False End Sub, Private Sub Text1_Change() Command1.Visible = True Command2.Visible = True End Sub 5,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3300 ClientLeft = 60 ClientTop = 450 ClientWidth = 4695 BeginProperty Font Name = "宋体" Size = 12 Charset = 134 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty LinkTopic = "Form1" ScaleHeight = 3300 ScaleWidth = 4695 StartUpPosition = 3 '窗口缺省 Begin VB.Timer Timer1 Enabled = 0 'False Interval = 500 Left = 3120 Top = 1320 End Begin VB.CommandButton Command2 Caption = "停止" Height = 495 Left = 2640 TabIndex = 1 Top = 2400 Width = 975 End Begin VB.CommandButton Command1 Caption = "移动" Height = 495 Left = 840 TabIndex = 0 Top = 2400 Width = 1095 End Begin VB.Image Image1 Height = 1800 Left = 840 Top = 360 Width = 1500 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Form_Load() Image1.Picture = LoadPicture("d:\tu3.jpg") End Sub Private Sub Command1_Click() Timer1.Enabled = True End Sub Private Sub Command2_Click() Timer1.Enabled = False End Sub Private Sub Timer1_Timer() Image1.Left = Int(Rnd * (Form1.ScaleWidth - Image1.Width)) Image1.Top = Int(Rnd * (Form1.ScaleHeight - Image1.Height)) End Sub 1,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 4305 ClientLeft = 60 ClientTop = 450 ClientWidth = 6345 BeginProperty Font Name = "宋体" Size = 14.25 Charset = 134 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty LinkTopic = "Form1" ScaleHeight = 4305 ScaleWidth = 6345 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "转换" Height = 495 Left = 2160 TabIndex = 2 Top = 1800 Width = 1455 End Begin VB.TextBox Text1 Height = 495 Left = 3480 TabIndex = 1 Top = 720 Width = 1455 End Begin VB.Label Label2 Height = 975 Left = 360 TabIndex = 3 Top = 2760 Width = 5775 End Begin VB.Label Label1 Caption = "请输入弧度数值:" Height = 495 Left = 600 TabIndex = 0 Top = 720 Width = 2415 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Sub Command1_Click() Dim x!, a!, aa%, b!, bb%, c!, cc$ x = Val(Text1) a = x * 180 / 3.14 aa = Int(a) b = (a - aa) * 60 bb = Int(b) c = (b - bb) * 60 cc = Format(c, "#.000") Label2 = "弧度" & Text1 & "转换为" & aa & "度" & bb & "分" & cc & " 秒" End Sub 2,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3255 ClientLeft = 60 ClientTop = 450 ClientWidth = 4980 LinkTopic = "Form1" ScaleHeight = 3255 ScaleWidth = 4980 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "判断" Height = 495 Left = 1560 TabIndex = 2 Top = 1440 Width = 1335 End Begin VB.TextBox Text1 Height = 615 Left = 960 TabIndex = 0 Top = 600 Width = 2655 End Begin VB.Label Label2 Height = 735 Left = 960 TabIndex = 3 Top = 2160 Width = 2775 End Begin VB.Label Label1 Caption = "输入一个年份:" Height = 375 Left = 1320 TabIndex = 1 Top = 240 Width = 1935 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim x% x = Val(Text1) If x / 400 = x \ 400 Or x Mod 4 = 0 And x Mod 100 <> 0 Then Label2 = Text1 & "年是闰年" Else Label2 = Text1 & "年不是闰年" End If End Sub 3,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "3个数排序" Height = 495 Left = 1800 TabIndex = 0 Top = 1320 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim x%, y%, z% x = InputBox("输入第一个数") y = InputBox("输入第二个数") z = InputBox("输入第三个数") If x > y Then t = x: x = y: y = t If y > z Then t = y: y = z: z = t If x > y Then t = x: x = y: y = t Print x, y, z End Sub 4,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 5430 ClientLeft = 60 ClientTop = 450 ClientWidth = 6975 LinkTopic = "Form1" ScaleHeight = 5430 ScaleWidth = 6975 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command2 Caption = "结束" Height = 495 Left = 3840 TabIndex = 1 Top = 2040 Width = 1215 End Begin VB.CommandButton Command1 Caption = "计费" Height = 495 Left = 1080 TabIndex = 0 Top = 2040 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() x = Val(InputBox("请输入上网时间:")) If x <> -1 Then Select Case x Case Is < 10 fei = 25 Case 10 To 50 fei = x * 2 Case 50 To 100 fei = x * 1.5 Case Is >= 100 fei = x * 1 End Select MsgBox "上网费用为:" & fei & "元" End If End Sub Private Sub Command2_Click() End End Sub 5,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.TextBox Text3 Height = 495 Left = 1320 TabIndex = 3 Text = "Text3" Top = 2520 Width = 975 End Begin VB.TextBox Text2 Height = 615 Left = 1320 TabIndex = 2 Text = "Text2" Top = 1680 Width = 975 End Begin VB.TextBox Text1 Height = 495 Left = 1320 TabIndex = 1 Text = "Text1" Top = 840 Width = 975 End Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 3360 TabIndex = 0 Top = 2640 Width = 975 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim a!, b!, c!, q!, p!, d! Cls a = Val(Text1): b = Val(Text2): c = Val(Text3) If a = 0 And b = 0 Then Print "这不是一个方程" Else If a = 0 Then Print "这不是一元二次方程" Else d = b ^ 2 - 4 * a * c p = -b / (2 * a) q = Sqr(Abs(d)) / (2 * a) If d > 0 Then Print "x1="; p + q Print "x2="; p - q ElseIf d = 0 Then Print "x1=x2="; p Else If q > 0 Then ch = "+" Else ch = "-" Print "x1="; p; ch; Abs(q); "i" Print "x1="; p; ch; Abs(q); "i" End If End If End If End Sub 1,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 1920 TabIndex = 0 Top = 1680 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() For i = 0 To 20 For j = 0 To 33 j) = 100 Then Print i, j, 100 If i * 5 + j * 3 + 1 / 3 * (100 - i - - i - j Next Next End Sub 2,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 1800 TabIndex = 0 Top = 1320 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() n = 0 Do If n Mod 2 = 1 And n Mod 3 = 2 And n Mod 5 = 4 And n Mod 6 = 5 And n Mod 7 = 0 Then Exit Do n = n + 1 Loop Print n End Sub 3,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command2 Caption = " 方法 快递客服问题件处理详细方法山木方法pdf计算方法pdf华与华方法下载八字理论方法下载 2" Height = 495 Left = 2880 TabIndex = 1 Top = 1320 Width = 1215 End Begin VB.CommandButton Command1 Caption = "方法1" Height = 495 Left = 2880 TabIndex = 0 Top = 480 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim x%, y%, z%, i%, j% For x = 0 To 9 For y = 0 To 9 For z = 0 To 9 i = x * 100 + x * 10 + z j = y * 100 + z * 10 + z If i + j = 532 Then Print x; y; z 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 4,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = "Form1" 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 = "Command1" Height = 495 Left = 1920 TabIndex = 0 Top = 1920 Width = 1215 End End Attribute VB_Name = "Form1" 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 5,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 1800 TabIndex = 0 Top = 1320 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() n = Val(InputBox("输入计算到第几项:", , 0)) For i = 1 To n s = s + (-1) ^ (i + 1) * i Next Print n, s End Sub 6,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 615 Left = 3120 TabIndex = 0 Top = 2400 Width = 1455 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim i%, s! For i = 1 To 4 s = s + i ^ i Next Print s End Sub 7,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = "Form1" 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 = "Form1" 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("输入计算到第几项:", , 0)) 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("输入计算到第几项:", , 0)) 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 8,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 2160 TabIndex = 0 Top = 1920 Width = 1215 End End Attribute VB_Name = "Form1" 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 9,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 1920 TabIndex = 0 Top = 1560 Width = 1215 End End Attribute VB_Name = "Form1" 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 10,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 615 Left = 3360 TabIndex = 0 Top = 2520 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim m%, t%, s% For m = 2 To 1000 s = 1 For t = 2 To m / 2 If m Mod t = 0 Then s = s + t Next If s = m Then Print m; "= 1 "; For t = 2 To m / 2 If m Mod t = 0 Then Print "+"; t; Next Print End If Next End Sub 12,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 3600 TabIndex = 0 Top = 2520 Width = 975 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim t!, h!, s! s = 100: h = 100 For t = 1 To 10 h = h / 2 s = s + h Next Print "共经过了"; s; "米" Print "第"; t - 1; "次反弹"; h; "米高" End Sub 12,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 2160 TabIndex = 0 Top = 1800 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() For n = 999 To 100 Step -1 For i = 2 To n - 1 If n Mod i = 0 Then Exit For Next i If i = n Then Print n k = k + 1 End If If k = 3 Then Exit For Next n End Sub 13,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 8025 LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 8025 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 1800 TabIndex = 0 Top = 1320 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() s = 0: Max = 0: Min = 1000 For i = 1 To 20 Randomize x = Int(Rnd * 49 + 51) Print x; If x > Max Then Max = x If x < Min Then Min = x s = s + x Next i aver = s / 20 Print Print "max="; Max, "min="; Min, "aver="; aver End Sub 14,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 3360 TabIndex = 0 Top = 2520 Width = 1095 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim n%, a%, b%, c%, d%, e%, f%, i%, x% Do n = InputBox("请输入总次数:") Loop Until n > 0 For i = 1 To n x = Int(Rnd * (6 - 1 + 1) + 1) If x = 1 Then a = a + 1 ElseIf x = 2 Then b = b + 1 ElseIf x = 3 Then c = c + 1 ElseIf x = 4 Then d = d + 1 ElseIf x = 5 Then e = e + 1 Else f = f + 1 End If Next Print " 点1出现的次数是"; a; ",百分比是"; Format(a / n, "##.00%") Print " 点2出现的次数是"; b; ",百分比是"; Format(b / n, "##.00%") Print " 点3出现的次数是"; c; ",百分比是"; Format(c / n, "##.00%") Print " 点4出现的次数是"; d; ",百分比是"; Format(d / n, "##.00%") Print " 点5出现的次数是"; e; ",百分比是"; Format(e / n, "##.00%") Print " 点6出现的次数是"; f; ",百分比是"; Format(f / n, "##.00%") End Sub 15,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command2 Caption = "方法2:双循环" Height = 495 Left = 2640 TabIndex = 1 Top = 1800 Width = 1575 End Begin VB.CommandButton Command1 Caption = "方法1:单循环" Height = 495 Left = 600 TabIndex = 0 Top = 1800 Width = 1455 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() For i = 1 To 4 Print Tab(20 - i); String(2 * i - 1, "*") Next End Sub Private Sub Command2_Click() For i = 1 To 4 Print Tab(30 - i); For j = 1 To 2 * i - 1 Print "*"; Next Print Next End Sub 1,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3990 ClientLeft = 60 ClientTop = 450 ClientWidth = 7095 LinkTopic = "Form1" ScaleHeight = 3990 ScaleWidth = 7095 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 4680 TabIndex = 0 Top = 2880 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim i%, a%(1 To 10), max%, min%, avg! max = 0: min = 100: avg = 0 For i = 1 To 10 a(i) = Int(Rnd * 51 + 50) Print a(i); If a(i) > max Then max = a(i) If a(i) < min Then min = a(i) avg = avg + a(i) Next i Print Print "--------------------" Print max, min, avg / 10 End Sub 2,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 4155 ClientLeft = 60 ClientTop = 450 ClientWidth = 6525 LinkTopic = "Form1" ScaleHeight = 4155 ScaleWidth = 6525 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 4680 TabIndex = 0 Top = 3120 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim a%(1 To 20), i%, y%, l%, z%, j%, b% For i = 1 To 20 a(i) = Int(Rnd * 101) Print a(i); If i Mod 10 = 0 Then Print Select Case a(i) Case 90 To 100 y = y + 1 Case 80 To 89 l = l + 1 Case Is >= 70 z = z + 1 Case Is >= 60 j = j + 1 Case Else b = b + 1 End Select Next i Print "优秀:"; y Print "良好:"; l Print "中:"; z Print "及格:"; j Print "不及格:"; b End Sub 3,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 4320 ClientLeft = 60 ClientTop = 450 ClientWidth = 6240 LinkTopic = "Form1" ScaleHeight = 4320 ScaleWidth = 6240 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 4440 TabIndex = 0 Top = 3360 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim a(1 To 10) As Integer, i%, j% For i = 1 To 10 a(i) = Int(Rnd * 50 + 1) Print a(i); Next i Print n = 10 For i = 1 To n - 1 For j = n To i + 1 Step -1 If a(j) > a(j - 1) Then t = a(j): a(j) = a(j - 1): a(j - 1) = t End If Next j Next i Print "-----------排序之后--------" For i = 1 To 10 Print a(i); Next i Print End Sub 4,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 4725 ClientLeft = 60 ClientTop = 450 ClientWidth = 6990 BeginProperty Font Name = "宋体" Size = 10.5 Charset = 134 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty LinkTopic = "Form1" ScaleHeight = 4725 ScaleWidth = 6990 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" BeginProperty Font Name = "宋体" Size = 9 Charset = 134 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Left = 5040 TabIndex = 0 Top = 3480 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim n%, a%(), i% n = InputBox("n") ReDim a(1 To n) Print "-----初值-----------------" For i = 1 To n '赋值 a(i) = Int(Rnd * 21 - 10) Print a(i); Next i Print For i = 1 To n - 1 '将相同值的数改为99 If a(i) <> 99 Then For j = i + 1 To n If a(j) = a(i) Then a(j) = 99 Next j End If Next i Print "-----重复的数值已经修改为99----------" For i = 1 To n '赋值 Print a(i); Next i Print Print "-----删除了重复数后的结果------------" '下面的代码将值为99的数组元素过滤掉 k = 0 For i = 1 To n If a(i) <> 99 Then k = k + 1 a(k) = a(i) End If Next i '打印剩余的k个不重复数 ReDim Preserve a(1 To k) For i = 1 To k Print a(i); Next i End Sub 5,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 4200 ClientLeft = 60 ClientTop = 450 ClientWidth = 7635 LinkTopic = "Form1" ScaleHeight = 4200 ScaleWidth = 7635 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command2 Caption = "方法2" Height = 495 Left = 5640 TabIndex = 1 Top = 2520 Width = 1215 End Begin VB.CommandButton Command1 Caption = "方法1" Height = 495 Left = 5640 TabIndex = 0 Top = 840 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim a(1 To 20) As Integer, i% For i = 1 To 20 a(i) = Int(Rnd * 101 + 1) 'Print a(i); 'If i Mod 5 = 0 Then Print If i Mod 5 = 0 Then Print a(i) Else Print a(i); Next i Print End Sub Private Sub Command2_Click() Dim a(1 To 20) As Integer, i% For i = 1 To 20 a(i) = Int(Rnd * 101 + 1) Print a(i); If i Mod 5 = 0 Then Print Next i End Sub 6,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 4440 ClientLeft = 60 ClientTop = 450 ClientWidth = 6480 LinkTopic = "Form1" ScaleHeight = 4440 ScaleWidth = 6480 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 4680 TabIndex = 0 Top = 3120 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click()Dim a%(1 To 9), b(1 To 3, 1 To 3) As Integer, i%, j% For i = 1 To 9 a(i) = Int(Rnd * 100) Print a(i); Next i Print For i = 1 To 3 For j = 1 To 3 b(i, j) = a((i - 1) * 3 + j) Next j Print Next i For i = 1 To 3 For j = 1 To 3 Print b(i, j); Next j Print Next i End Sub 7,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 4080 ClientLeft = 60 ClientTop = 450 ClientWidth = 6225 LinkTopic = "Form1" ScaleHeight = 4080 ScaleWidth = 6225 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 4800 TabIndex = 0 Top = 3360 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim a() As Integer, i% n = InputBox("n") ReDim a(1 To n, 1 To n) For i = 1 To n For j = 1 To n a(i, j) = Int(Rnd * 100) Print a(i, j); Next j Print Next i End Sub 8,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 4395 ClientLeft = 60 ClientTop = 450 ClientWidth = 7230 LinkTopic = "Form1" ScaleHeight = 4395 ScaleWidth = 7230 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 5160 TabIndex = 0 Top = 3240 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim a() As Integer, i% n = InputBox("n") ReDim a(1 To n, 1 To n) For i = 1 To n For j = 1 To n If (i = j) Or (i + j = n + 1) Then a(i, j) = 1 Else a(i, j) = 0 Print a(i, j); Next j Print Next i End Sub 9,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 4350 ClientLeft = 60 ClientTop = 450 ClientWidth = 7005 LinkTopic = "Form1" ScaleHeight = 4350 ScaleWidth = 7005 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 5280 TabIndex = 0 Top = 3120 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim a(), i%, j%, m%, n% m = InputBox("M") n = InputBox("n") ReDim a(1 To m, 1 To n) For i = 1 To m For j = 1 To n a(i, j) = Int(Rnd * 100) Print a(i, j); Next j Print Next i Dim max%, imax%, jmax% max = a(1, 1): imax = 1: jmax = 1 For i = 1 To m For j = 1 To n If a(i, j) > max Then max = a(i, j) imax = i jmax = j End If Next j Next i Print "--------------" Print max, imax, jmax End Sub 10,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 4935 ClientLeft = 60 ClientTop = 450 ClientWidth = 7155 LinkTopic = "Form1" ScaleHeight = 4935 ScaleWidth = 7155 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 4920 TabIndex = 0 Top = 3600 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim a(), i%, j%, m%, n% m = InputBox("M") n = InputBox("n") ReDim a(1 To m, 1 To n) For i = 1 To m For j = 1 To n a(i, j) = Int(Rnd * 100) Print a(i, j); Next j Print Next i Print "----------------------------" ReDim Preserve a(1 To m, 1 To n + 1) '计算i行的和,放入第n+1列 For i = 1 To m a(i, n + 1) = 0 For j = 1 To n a(i, n + 1) = a(i, n + 1) + a(i, j) Next j Next i For i = 1 To m For j = 1 To n + 1 Print a(i, j); Next j Print Next i End Sub 1,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 3360 TabIndex = 0 Top = 2520 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Function f(x) As Integer If x < 0 Then f = -1 ElseIf x > 0 Then f = 1 Else f = 0 End If End Function 2,VERSION 5.00 Begin VB.Form Form1 AutoRedraw = -1 'True Caption = "Form1" ClientHeight = 3555 ClientLeft = 60 ClientTop = 450 ClientWidth = 5760 LinkTopic = "Form1" ScaleHeight = 3555 ScaleWidth = 5760 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 3600 TabIndex = 0 Top = 2280 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim n, flag As Integer ")) n = Val(InputBox("输入任意一个数 sushu n, flag Print n; "的标志是"; flag End Sub Public Sub sushu(n, flag) flag = 1 For i = 2 To n - 1 If n Mod i = 0 Then flag = 0: Exit For Next i End Sub 3,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3660 ClientLeft = 60 ClientTop = 450 ClientWidth = 5895 BeginProperty Font Name = "黑体" Size = 24 Charset = 134 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty LinkTopic = "Form1" ScaleHeight = 3660 ScaleWidth = 5895 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command2 Caption = "过程形式" BeginProperty Font Name = "宋体" Size = 18 Charset = 134 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 615 Left = 3600 TabIndex = 1 Top = 2760 Width = 1935 End Begin VB.CommandButton Command1 Caption = "函数形式" BeginProperty Font Name = "宋体" Size = 18 Charset = 134 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 615 Left = 600 TabIndex = 0 Top = 2760 Width = 1935 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Rem 利用函数过程求 n!/(m!.(n-m)!) Function fact2(x) t = 1 For i = 1 To x t = t * i Next i fact2 = t End Function Private Sub Command1_Click() m = Val(InputBox("输入 N")) n = Val(InputBox("输入 M")) s1 = fact2(n) s2 = fact2(m) m) s3 = fact2(n - Print "函数法结果为"; s1 / (s2 * s3) End Sub Rem 利用子程序过程求 n!/(m!.(n-m)!) Sub fact1(ByVal x As Integer, t) t = 1 For i = 1 To x t = t * i Next i End Sub Private Sub Command2_Click() m = Val(InputBox("n=")) n = Val(InputBox("m=")) fact1 n, s1 fact1 m, s2 fact1 n - m, s3 Print "子过程结果"; s1 / (s2 * s3) End Sub 4,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 4305 ClientLeft = 60 ClientTop = 450 ClientWidth = 6945 BeginProperty Font Name = "黑体" Size = 26.25 Charset = 134 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty LinkTopic = "Form1" ScaleHeight = 4305 ScaleWidth = 6945 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 615 Left = 3960 TabIndex = 0 Top = 3360 Width = 2775 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() n = InputBox("任意输入一个数") " Else Print n; "不是" If hws(n) = True Then Print n; "是 End Sub Function hws(x) As Boolean Print x hws = True For i = 1 To Len(x) \ 2 If Mid(x, i, 1) <> Mid(x, Len(x) + 1 - i, 1) Then hws = False Exit For End If Next i End Function 5,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 3360 TabIndex = 0 Top = 2640 Width = 1095 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim n%, m% For i = 1 To 20 m = m + 1 Print Tab((m - 1) * 8 + 1); fib(i); If i Mod 5 = 0 Then Print m = 0 End If Next Print End Sub Function fib(t) As Integer If t = 1 Or t = 2 Then fib = 1 Else fib = fib(t - 1) + fib(t - 2) End If End Function 6,VERSION 5.00 Begin VB.Form Form1 AutoRedraw = -1 'True Caption = "Form1" ClientHeight = 3555 ClientLeft = 60 ClientTop = 450 ClientWidth = 5760 LinkTopic = "Form1" ScaleHeight = 3555 ScaleWidth = 5760 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 3840 TabIndex = 0 Top = 2280 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim n, sum As Integer n = Val(InputBox("n=?")) sum = jsh(n) Print "1!+2!+...+"; n; "!="; sum End Sub Public Function jsh(n) As Integer Dim i, s, t As Integer s = 0 t = 1 For i = 1 To n t = t * i s = s + t Next i jsh = s End Function 7,VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 615 Left = 3360 TabIndex = 0 Top = 2520 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim a!, b!, c!, x1!, x2! a = InputBox("a=?") b = InputBox("b=?") c = InputBox("c=?") If a = 0 And b = 0 Then Print "不是一个方程" ElseIf a = 0 Then Print "不是一个一元二次方程" x = -c / b Print "x="; x Else If b ^ 2 - 4 * a * c >= 0 Then Call root(a, b, c, x1, x2) Print "x1="; x1 Print "x2="; x2 Else Print "无实数根" End If End If End Sub Sub root(ByVal a!, ByVal b!, ByVal c!, x1!, x2!) d = b ^ 2 - 4 * a * c x1 = (-b + Sqr(d)) / (2 * a) x2 = (-b - Sqr(d)) / (2 * a) End Sub
本文档为【VB课后答案】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_240534
暂无简介~
格式:doc
大小:233KB
软件:Word
页数:0
分类:其他高等教育
上传时间:2017-10-17
浏览量:23