1.Private Sub Command1_Click()Dim r As Double, c As Double, s As DoubleDim pi As Doublepi = 3.1415926r = Val(Text1.Text)c = pi * 2 * rs = pi * r * rLabel3.Caption = "圆的周长为" + Str(c) + "厘米"Label4.Caption = "圆的面积为" + Str(s) + "平方厘米"End Sub2.(5秒5分倒计时)Dim n As IntegerPrivate Sub Command1_Click()If Option1.Value Then n = 5If Option2.Value Then n = 300Timer1.Enabled = TrueFrame1.Enabled = FalseCommand1.Enabled = FalseEnd SubPrivate Sub Form_Load()Timer1.Enabled = FalseTimer1.Interval = 1000End SubPrivate Sub Timer1_Timer()n = n - 1Text1.Text = Str(n \ 60) & "分" & Str(n Mod 60) & "秒"If n <= 0 ThenTimer1.Enabled = FalseFrame1.Enabled = TrueText1.Text = "时间到"End IfEnd Sub3.心想事成Dim x As IntegerPrivate Sub Command1_Click()Timer1.Enabled = TrueIf Command1.Caption = "开始" ThenTimer1.Enabled = TrueCommand1.Caption = "停止"ElseTimer1.Enabled = FalseCommand1.Caption = "开始"End IfEnd SubPrivate Sub Form_Load()Timer1.Interval = 100x = -100End SubPrivate Sub Timer1_Timer()Label1.Left = Label1.Left + xIf Label1.Left <= 0 Then x = 100If Label1.Left >= Form1.ScaleWidth -Label1.Width Then x = -100End Sub4.我的调色板(滚动条)Private Sub Command1_Click()Label5.ForeColor = Label4.BackColor End SubPrivate Sub HScroll1_Change()Label4.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)End SubPrivate Sub HScroll2_Change()Label4.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)End SubPrivate Sub HScroll3_Change()Label4.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)End Sub5.字形字体颜色(复选框,单选)Private Sub Check1_Click()If Check1.Value = 1 ThenText1.FontBold = TrueElseText1.FontBold = FalseEnd IfEnd SubPrivate Sub Check2_Click()If Check1.Value = 1 ThenText1.FontItalic = TrueElseText1.FontItalic = FalseEnd IfEnd SubPrivate Sub Check3_Click()If Check1.Value = 1 ThenText1.FontUnderline = TrueElseText1.FontUnderline = FalseEnd IfEnd SubPrivate Sub Option1_Click()Text1.FontName = Option1.Caption End SubPrivate Sub Option2_Click()Text1.FontName = Option2.Caption End SubPrivate Sub Option3_Click()Text1.FontName = Option3.Caption End SubPrivate Sub Option4_Click()Text1.ForeColor = vbRedEnd SubPrivate Sub Option5_Click()Text1.ForeColor = vbBlueEnd SubPrivate Sub Option6_Click()Text1.ForeColor = vbGreenEnd Sub6.(加减乘除计算)Private Sub Command1_Click()Option1.Value = FalseOption2.Value = FalseOption3.Value = FalseOption4.Value = FalseEnd SubPrivate Sub Option1_Click()Label1.Caption = Option1.CaptionText3.Text = Val(Text1.Text) +Val(Text2.Text)End SubPrivate Sub Option2_Click()Label1.Caption = Option2.CaptionText3.Text = Val(Text1.Text) -Val(Text2.Text)End SubPrivate Sub Option3_Click()Label1.Caption = Option3.CaptionText3.Text = Val(Text1.Text) *Val(Text2.Text)End SubPrivate Sub Option4_Click()Label1.Caption = Option4.CaptionIf Val(Text2.Text) = 0 ThenMsgBox "除数不得为零"ElseText3.Text = Val(Text1.Text) / Val(Text2.Text)End IfEnd Sub7.(输入密码,你有3次机会)Private Sub Command1_Click()Static x As IntegerIf Text2.Text = "123" ThenForm2.ShowForm1.HideElsex = x + 1If x > 2 ThenLabel3.Caption = "密码错误,禁止输入,请退出程序"Text2.Enabled = FalseCommand1.Enabled = FalseElseLabel3.Caption = "密码错误,您还有" & 3 - x & "次机会"End IfEnd IfEnd SubPrivate Sub Command2_Click()EndEnd SubPrivate Sub Form_Load()Text2.Text = ""End Sub8.(字体字形字号下拉组合框)Private Sub Combo1_Click()Label4.FontName = Combo1.TextEnd SubPrivate Sub Combo2_Click()Select Case Combo2.TextCase "常规"Label4.FontBold = FalseLabel4.FontItalic = FalseCase "加粗"Label4.FontBold = TrueCase "倾斜"Label4.FontItalic = TrueCase "加粗倾斜"Label4.FontBold = TrueLabel4.FontItalic = TrueEnd SelectEnd SubPrivate Sub Combo3_Change()If Val(Combo3.Text) > 0 And Val(Combo3.Text) <= 40 ThenLabel4.FontSize = Val(Combo3.Text)ElseLabel4.FontSize = 10MsgBox "请输入一个0-40之间的数"End IfEnd SubPrivate Sub Combo3_Click()Label4.FontSize = Val(Combo3.Text)End SubPrivate Sub Form_Load()Combo1.AddItem "宋体"Combo1.AddItem "楷体"Combo1.AddItem "黑体"Combo1.AddItem "隶书"Combo1.Text = "宋体"Combo2.AddItem "加粗"Combo2.AddItem "倾斜"Combo2.AddItem "常规"Combo2.AddItem "加粗倾斜"Combo2.Text = "常规"For i = 10 To 40 Step 2Combo3.AddItem iNext iCombo3.Text = 10End Sub9.(右移,左移,全部右移)Private Sub Command1_Click()If List1.ListIndex = -1 ThenMsgBox "请先选择一个城市!"ElseCombo1.AddItem List1.TextList1.RemoveItem List1.ListIndexEnd IfEnd SubPrivate Sub Command2_Click()If Combo1.ListIndex = -1 ThenMsgBox "请先选择一个城市!"ElseList1.AddItem Combo1.TextCombo1.RemoveItemCombo1.ListIndexEnd IfEnd SubPrivate Sub Command3_Click()List1.ClearCombo1.AddItem "上海"Combo1.AddItem "厦门"Combo1.AddItem "广东"Combo1.AddItem "浙江"Combo1.AddItem "北京"End SubPrivate Sub Form_Load()List1.AddItem "上海"List1.AddItem "厦门"List1.AddItem "广东"List1.AddItem "浙江"List1.AddItem "北京"End Sub10.(找最大值)Option ExplicitPrivate Sub Command1_Click()Dim a As IntegerDim i As IntegerDim max As Integeri = 1For i = 1 To 10 Step 1Randomizea = Int(Rnd * 90) + 10If max < a Then max = a Print a;Next iPrintPrint "最大值max=" & max End Sub11.(找水仙花数)Private Sub Command1_Click()Dim i As IntegerDim b As IntegerDim c As IntegerDim d As IntegerFor i = 100 To 999 Step 1b = i \ 100c = i \ 10 Mod 10d = i Mod 10If i = b ^ 3 + c ^ 3 + d ^ 3 ThenPrint iEnd IfNext iEnd SubPrivate Sub Command2_Click()Dim i As IntegerDim b As IntegerDim c As IntegerDim d As Integeri = 100While i < 999b = i \ 100c = i \ 10 Mod 10d = i Mod 10If i = b ^ 3 + c ^ 3 + d ^ 3 ThenPrint iEnd Ifi = i + 1Wend End Sub12.(滚动条)Private Sub Form_Load()Text1.Text = HS1.ValueEnd SubPrivate Sub HS1_Change()Text1.Text = HS1.ValueEnd SubPrivate Sub HS1_Scroll()Text1.Text = "拖动中"End SubPrivate Sub Text1_Change()If Val(Text1.Text) >= 1 And Val(Text1.Text) <= 50 ThenHS1.Value = Val(Text1.Text)ElseMsgBox "请输入大于0小于50的数值"End IfEnd Sub13.显示时间Private Sub Timer1_Timer()Text1.Text = TimeEnd Sub14.(心想事成)Private Sub Command1_Click()Timer1.Enabled = TrueIf Command1.Caption = "开始" ThenTimer1.Enabled = TrueCommand1.Caption = "停止"ElseTimer1.Enabled = FalseCommand1.Caption = "开始"End IfEnd SubPrivate Sub Timer1_Timer()If Label1.Left >= Label1.Width ThenLabel1.Left = Label1.Left - 100 ElseLabel1.Left = Form1.WidthEnd IfEnd Sub15.(图片复制,输出文字)Private Sub Command2_Click()Picture1.ForeColor = vbRedPicture1.Print "请猜出片名" + vbCrLfPicture1.Print "不知道?"End SubPrivate Sub Command3_Click()EndEnd SubPrivate Sub Command1_Click()Picture2.Picture = Picture1.Picture End SubPrivate Sub Form_Load()Picture2.Width = Picture1.WidthPicture2.Height = Picture1.HeightPicture2.AutoSize = TruePicture1.Picture =LoadPicture(App.Path + "\images\郁金香.jpg")Picture2.Picture =LoadPicture(App.Path + "\images\玫瑰.jpg")End Sub16.(图像)Private Sub Form_Load()Image1.Picture = LoadPicture(App.Path + "\images\郁金香.jpg")Image2.Picture = LoadPicture(App.Path + "\images\玫瑰.jpg")Image3.Picture = LoadPicture(App.Path + "\images\康乃馨.jpg")Image4.Picture = LoadPicture(App.Path + "\images\绣球花.jpg")End SubPrivate Sub Image1_Click()Picture1.ClsImage5.Picture = Image1.PicturePicture1.Print "这是郁金香"End SubPrivate Sub Image2_Click()Picture1.ClsImage5.Picture = Image2.PicturePicture1.Print "这是玫瑰"End SubPrivate Sub Image3_Click()Picture1.ClsImage5.Picture = Image3.PicturePicture1.Print "这是康乃馨"End SubPrivate Sub Image4_Click()Picture1.ClsImage5.Picture = Image4.PicturePicture1.Print "这是绣球花"End Sub17.(改变大小,圆的半径随滚动条变化)Private Sub Form_Load()HScroll1.Value = 3400Shape1.Height = HScroll1.ValueShape1.Width = HScroll1.ValueLabel2.Caption = HScroll1.ValueShape1.Left = Form1.ScaleWidth / 2 - Shape1.Width / 2Shape1.Top = Form1.ScaleHeight / 2 - Shape1.Height / 2 - 1000End SubPrivate Sub HScroll1_Change()Shape1.Height = HScroll1.ValueShape1.Width = HScroll1.ValueLabel2.Caption = HScroll1.ValueShape1.Left = Form1.ScaleWidth / 2 - Shape1.Width / 2Shape1.Top = Form1.ScaleHeight / 2 - Shape1.Height / 2 - 1000End Sub18.(数组生成,数组打印)Option Base 1Dim a(30) As DoublePrivate Sub Command1_Click()a(1) = 1a(2) = 1Dim i As DoubleFor i = 3 To 30a(i) = a(i - 1) + a(i - 2)Next iMsgBox "已经生成数组"End SubPrivate Sub Command2_Click()Dim i As DoubleFor i = 1 To 30Print a(i);If i Mod 10 = 0 ThenPrintEnd IfNext iEnd Sub19.(最大值输出)Option ExplicitOption Base 1Private Sub Command1_Click()Dim a(15) As LongDim position As Integer, i As IntegerDim temp As LongFor i = 1 To 15a(i) = Int(InputBox("请输入15个不同的数:"))Print a(i)Next iPrintposition = 1For i = 2 To 15If a(position) < a(i) Then position = iNext itemp = a(1)a(1) = a(position)a(position) = tempPrint "最大值的位置:" & positionFor i = 1 To 15Print a(i)Next iPrint End Sub20.(一次任意打印10个数,从大到小排列)Option Base 1Private Sub Command1_Click()Dim a(10) As LongDim i As Integer, k As Integer, temp As Long, j As LongFor i = 1 To 10Randomizea(i) = Int(Rnd * 10)Next iFor i = 1 To 10Print a(i);If i Mod 5 = 0 Then PrintNext iPrintFor j = 1 To 9k = jFor i = j + 1 To 10If a(i) > a(k) Then k = iNext itemp = a(j): a(j) = a(k): a(k) = temp Next jFor i = 1 To 10Print a(i);If i Mod 5 = 0 Then PrintNext iPrintEnd Sub21.(将打印的数对应复制的文本框)Option Base 1Private Sub Command1_Click()Dim a(10) As LongDim i As Integer, k As Integer, temp As Long, j As LongFor i = 1 To 10Randomizea(i) = Int(Rnd * 10)Next iFor i = 1 To 10Print a(i);If i Mod 5 = 0 Then PrintText1(i - 1).Text = Str(a(i))Next iPrintFor j = 1 To 9k = jFor i = j + 1 To 10If a(i) < a(k) Then k = iNext itemp = a(j): a(j) = a(k): a(k) = temp Next jFor i = 1 To 10Text1(i - 1).Text = Str(a(i))Next iFor i = 1 To 10Print a(i);If i Mod 5 = 0 Then PrintNext iPrintEnd Sub22.(数转置,清空)Private Sub Command1_Click()Dim a(10) As StringDim b As String * 1Dim i As IntegerFor i = 1 To Len(Text1.Text)a(i) = Mid(Text1.Text, i, 1)Next iFor i = 1 To Len(Text1.Text) \ 2b = a(i)a(i) = a(Len(Text1.Text) + 1 - i)a(Len(Text1.Text) + 1 - i) = bNext iFor i = 1 To Len(Text1.Text)Text2.Text = Text2.Text & a(i)Next iEnd SubPrivate Sub Command2_Click()Text1.Text = ""Text2.Text = ""End Sub23.(计时抽奖,中奖号码为)5个文本框Private Sub Command1_Click(Index As Integer)Dim i As IntegerSelect Case IndexCase 0Timer1.Enabled = TrueLabel1.Caption = "本次中奖号码为:"Case 1Timer1.Enabled = FalseFor i = 0 To 4Label1.Caption = Label1.Caption & Text1(i).TextNext iCase 2EndEnd SelectEnd SubPrivate Sub Timer1_Timer()Dim i As IntegerFor i = 0 To 4Text1(i).Text = Int(Rnd * 10)Next iEnd Sub24.计算三角形面积Private Sub Form_Click()Dim a As Integer, b As Integer, c As Integer, t As Integera = Val(InputBox("输入a的值"))b = Val(InputBox("输入b的值"))c = Val(InputBox("输入c的值"))t = (a + b + c) / 2s = MsgBox(Str((t * (t - a) * (t - b) * (t - c)) ^ 0.5))End Sub25.数位分解Private Sub Command1_Click()Dim a As Integer, b As Integer, c As Integer, d As Integera = Val(Text1.Text)b = a \ 100c = a \ 10 Mod 10d = a Mod 10Label1.Caption = "三位数字" + Str(a) + "百位数字" + Str(b)Label2.Caption = "三位数字" + Str(a) + "十位数字" + Str(c)Label3.Caption = "三位数字" + Str(a) + "个位数字" + Str(d)End Sub26.随机二位整数加法Private Sub Command1_Click()Dim a As Integer, b As Integer, c As Integera = Int(Rnd * 90) + 10b = Int(Rnd * 90) + 10c = a + bText1.Text = Str(a)Text2.Text = bText3.Text = cEnd SubPrivate Sub Command2_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""End SubPrivate Sub Command3_Click()EndEnd SubPrivate Sub Text1_Change()If keyascii > Asc("0") Or keyascii < Asc("9") Thenkeyascii = 0End IfEnd SubPrivate Sub Text2_Change() Text3.Text = Val(Text1.Text) + Val(Text2.Text) End SubPrivate Sub Text3_Change()Text3.Text = Val(Text1.Text) + Val(Text2.Text) End Sub。