Private Sub Command1_Click() Dim an As Integer an = MsgBox("你确定要离开我吗?TAT", 1, "离开") If an = 1 Then 'Exit Sub ' 退出事件 MsgBox "泪奔QAQ" End Else MsgBox "乖~~~~" End If End Sub
Private Sub Command2_Click() MsgBox "今天是" + Str(Date), 0, "提示日期" End Sub
Private Sub Command3_Click() Dim a As Integer, i As Integer, sum As Long, pro As Long Dim flag As Boolean a = Val(Text1.Text) b = Val(Text2.Text) For i = a To b Step 1 sum = sum + i If sum >= 100000 Then flag = 1: Exit For Next i If flag = True Then List1.AddItem "∑a~b 结果溢出" Else List1.AddItem "∑a~b" + Str(sum) End If pro = 1 sum = 1 i = a Do While i <= b i = i + 1 pro = pro * i If pro >= 100000 Then flag = 1: Exit Do Loop If flag = True Then List1.AddItem "∏a~b 结果溢出" Else List1.AddItem "∏a~b" + Str(pro) End If List1.AddItem "a*b的根号" + Str(Format$(Sqr(a * b), "0.00")) End Sub Private Sub Command4_Click() Label1.Caption = "" End Sub Function gcd(a As Integer, b As Integer) As Integer Do While b <> 0 Dim t As Integer t = b b = a Mod b a = t Loop gcd = a End Function
Private Sub Command5_Click() Dim a As Integer, b As Integer a = Val(Text1.Text) b = Val(Text2.Text) Label1.Caption = "最大公约数 " + Str(gcd(a, b)) End Sub
Private Sub Command6_Click() Label1.BorderStyle = 0 End Sub
Private Sub Command7_Click() Label1.BorderStyle = 1 End Sub
Private Sub Command8_Click() Label1.Font = "隶书" End Sub