1、家电维修社团整理 - 1 -更多精彩,静待家电维修P37#2-4Private Sub cmdBegin_Click()Timer1.Enabled = True 激活定时器cmdBegin.Enabled = FalsecmdEnd.Enabled = TrueEnd SubPrivate Sub cmdEnd_Click()Timer1.Enabled = False 关闭定时器Label1.Left = 0 标签归位到窗体左侧cmdBegin.Enabled = TruecmdEnd.Enabled = FalseEnd SubPrivate Sub Form_Load()Label1.
2、Left = 0 初始将标签归位到窗体左侧End SubPrivate Sub Timer1_Timer()Label1.Move Label1.Left + 20 每隔 0.1秒标签向右移动 20缇End Sub2-5Dim tmpPrivate Sub Command1_Click() “复制”按钮Text1.SetFocus 焦点定位在文本框 Text1tmp = Text1.SelText 将选中的内容存放在变量 tmp中End SubPrivate Sub Command2_Click() “剪切”按钮tmp = Text1.SelText 将选中的内容存放在变量 tmp中Text1
3、.SelText = “ 将选中的内容置为空串Text1.SetFocus 焦点定位在文本框 Text1End SubPrivate Sub Command3_Click() “粘贴”按钮Text1.SelText = tmp 将变量 tmp的值赋给文本框选中的内容Text1.SetFocus 焦点定位在文本框 Text1End SubPrivate Sub Command4_Click() “下划线”按钮Text1.FontUnderline = Not Text1.FontUnderline 设置或取消下划线End SubPrivate Sub Command5_Click() “删除线”
4、按钮Text1.FontStrikethru = Not Text1.FontStrikethru 设置或取消删除线End SubPrivate Sub Command6_Click() “加粗”按钮Text1.FontBold = Not Text1.FontBold 设置或取消加粗线End SubPrivate Sub Command7_Click() “倾斜”按钮Text1.FontItalic = Not Text1.FontItalic 设置或取消倾斜End SubPrivate Sub Command8_Click() “放大”按钮Text1.FontSize = Text1.Fo
5、ntSize + 5 字体放大 5磅End SubPrivate Sub Command9_Click() “缩小”按钮Text1.FontSize = Text1.FontSize - 5 字体缩小 5磅End SubP38#2-8Private Sub Form_Load() 在开始运行时设置各文本框的文字大小和字体Text2.FontName = “隶书“Text2.FontSize = 16Text3.FontName = “楷体_GB2312“Text3.FontSize = 18End SubPrivate Sub Text1_Change() 在 Text1中改变内容时改变Tex
6、t2和 Text3的内容Text2.Text = Text1.Text家电维修社团整理 - 2 -更多精彩,静待家电维修Text3.Text = Text1.TextEnd SubPrivate Sub Command1_Click() 清除按钮Text1.Text = “End SubPrivate Sub Command2_Click() 退出按钮EndEnd Sub2-9Private Sub Command1_Click()Command1.Visible = FalseCommand2.Visible = TrueLabel1.BorderStyle = 1End SubPrivat
7、e Sub Command2_Click()Command1.Visible = TrueCommand2.Visible = FalseLabel1.BorderStyle = 0End SubPrivate Sub Command3_Click()Command3.Visible = FalseCommand4.Visible = TrueLabel1.BackStyle = 1End SubPrivate Sub Command4_Click()Command3.Visible = TrueCommand4.Visible = FalseLabel1.BackStyle = 0End S
8、ubP60/613-1Private Sub Command1_Click()Const pi = 3.1415926535898Dim h As SingleDim r As Singleh = Val(Text1.Text)r = Val(Text2.Text)Text3.Text = Format(pi * r 2, “0.000“)Text4.Text = Format(2 * pi * r * h, “0.000“)Text5.Text = Format(pi * r 2 * h, “0.000“)End Sub3-2Private Sub Command1_Click()Rando
9、mizeText1.Text = Int(Rnd * 100 + 1)Text2.Text = Int(Rnd * 100 + 1)Text3.Text = “End SubPrivate Sub Command2_Click()Text3.Text = Val(Text1.Text) + Val(Text2.Text)End Sub3-4Private Sub Timer1_Timer()y = Year(Date) 求当前日期的年份mon = Month(Date) 求当前日期的月份d = Day(Date) 求当前日期是月份中的第几天Label1.Caption = y “小时“; m;
10、 “分“; s; “秒=“; Total; “秒“End SubP895-5Private Sub Text1_Change()Label2.Caption = “End SubPrivate Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)Static I As Integer 变量 I统计输入错误口令的次数If KeyCode = 13 Then 如果按下的键为回车键If UCase(Text1.Text) = “HELLO“ Then 如果口令为“HELLO“Label2.Caption = “恭喜!,您已成功进入本系统“Else
11、If I = 0 Or I = 1 Then 如果口令错且错误次数少于 2I = I + 1Label2.Caption = “口令错!,请重新输入“Text1.SelStart = 0Text1.SelLength = Len(Text1.Text)Else 如果口令错且错误次数等于 2MsgBox “对不起,您不能使用本系统“End 退出应用程序。End IfEnd IfEnd SubP92#5-1Private Sub Command1_Click()x = Val(Text1.Text)If x Mod 3 = 0 And x Mod 5 = 0 And x Mod 7 = 0 The
12、n Text2.Text = “能同时被 3、5、7 整除“ Else Text2.Text = “不能整除“End Sub5-2家电维修社团整理 - 4 -更多精彩,静待家电维修Private Sub Form_Load()Dim x As Single, y As Single, z As Single, max As Single, min As Singlex = InputBox(“第一个“)y = InputBox(“第二个“)z = InputBox(“第三个“)If x y Thenmax = xElse: max = yEnd IfIf max z Thenmin = zw
13、= MsgBox(“ 最小值 “ “; Format(J); “=“; Format(I * J, “!“);Next JPicture1.PrintNext IEnd SubB*Private Sub Picture1_Click()For I = 1 To 9For J = 1 To IPicture1.Print Format(I); “; Format(J); “=“; Format(I * J, “!“);Next JPicture1.PrintNext IEnd SubP106#6-11Dim N As IntegerPrivate Sub Command1_Click() “求最
14、大公约数”按钮的事件过程M = Val(Text1.Text): N = Val(Text2.Text) 输入M,NA = M: B = N 将 M、N 暂时保存在变量 A、B 中,用于求最小公倍数R = M Mod N 求 M除以 N的余数 RDo While R 0 当余数 R不为 0时执行循环体M = N 将除数 N做为新的被除数 MN = R 将余数 R做为新的除数 NR = M Mod N 求 M除以 N的余数 RLoopLabel3.Caption = N 输出最大公约数 NCommand2.Enabled = TrueEnd SubPrivate Sub Command2_Cli
15、ck() “求最小公倍数“按钮的事件过程Label4.Caption = Val(Text1.Text) * Val(Text2.Text) / NEnd Sub家电维修社团整理 - 6 -更多精彩,静待家电维修6-12Private Sub Command1_Click()N = Val(Text1.Text): K = Int(Sqr(N): I = 2Do While I 0 ThenI = I + 1 不能整除,ID 的值累加 1ElseExit Do 整除,退出循环End IfLoopIf I 0num1 = num1 + 1sum1 = sum1 + A(i)Case Is Max
16、 ThenMax = a(i)End IfNext iText2.Text = MaxEnd Sub7-5Dim A(1 To 20) As IntegerPrivate Sub Command1_Click()Text1.Text = “RandomizeFor i = 1 To 20A(i) = Int(Rnd * 50 + 1)Text1.Text = Text1.Text Next jPicture1.PrintNext iEnd SubPrivate Sub Command2_Click()RandomizePicture2.ClsFor i = 1 To 6For j = 1 To
17、 6b(i, j) = a(j, i)Picture2.Print Format(b(i, j), “!“);Next jPicture2.PrintNext iEnd Sub7-11Dim a() As Integer, n As IntegerPrivate Sub Form_click()Form1.Clsn = Val(InputBox(“请输入行数“, , “10“)ReDim a(1 To n, 1 To n)a(1, 1) = 1For i = 2 To na(i, 1) = 1a(i, i) = 1For j = 2 To i - 1a(i, j) = a(i - 1, j -
18、 1) + a(i - 1, j)Next jNext iFor i = 1 To nFor j = 1 To iPrint Format(a(i, j), “!“);Next jPrintNext iEnd Sub7-12Dim n As Integer, x As IntegerPrivate Sub Command1_Click()n = n + 1 控件数组的最大下标值加 1Load Text1(n) 添加一个文本框Text1(n).Visible = True 使新加的文本框可见Text1(n).Left = Text1(n - 1).Left + Text1(n - 1).Width
Copyright © 2018-2021 Wenke99.com All rights reserved
工信部备案号:浙ICP备20026746号-2
公安局备案号:浙公网安备33038302330469号
本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。