DOC

vb

By Maria Perkins,2014-05-27 05:55
8 views 0
vb

黑白格布

    

2-1

    Private Sub Form_Click()

     Cls

    End Sub

    Private Sub Form_DblClick()

     FontSize = 40

     FontName = "隶书"

     ForeColor = vbRed

     Print "热烈庆祝"

     FontSize = 60

     FontName = "宋体"

     ForeColor = vbGreen

     Print "河南大学运动会召开" End Sub

    2-22-4

    Private Sub Timer1_Timer()

     Text1.Text = Now

     Caption = Text1.Text

    End Sub

    2-5

    Private Sub Timer1_Timer()

     If BackColor = vbRed Then

     BackColor = vbYellow

     Else

     BackColor = vbRed

     End If

    End Sub

    2-6

    Private Sub Timer1_Timer()

     If Label1.Left < Form1.Width Then

     Label1.Left = Label1.Left + 200

     Else

     Label1.Left = -Label1.Left

     End If

    End Sub

    2-7

    Private Sub Command1_Click()

     Text1.Visible = True

    End Sub

    Private Sub Command2_Click()

     Text1.Visible = False

    End Sub

    2-8

    Private Sub Text1_Change()

     Text2.Text = Text1.Text

    End Sub

    2-9

    Private Sub Command1_Click()

     FontSize = 20

     FontBold = True

     Print "欢迎来到"

     Print "河南大学"

    End Sub

    Private Sub Command2_Click()

     Cls

    End Sub

    Private Sub Command3_Click()

     End

    End Sub

    2-10

    Private Sub Command1_Click()

     r = Text1.Text

     Text2.Text = 3.14 * 2 * r

    End Sub

    Private Sub Command2_Click()

     Text1.Text = " "

     Text2.Text = " "

     Text1.SetFocus

    End Sub

    2-11

    Private Sub Form_Load()

     Text1.Text = "河南大学欢迎您?"

     Text1.FontName = "宋体"

     Text1.FontSize = 50

     Text1.BackColor = vbYellow

     Text1.ForeColor = vbBlue End Sub

    2-12

     Dim s As String

    Private Sub Command1_Click()

     s = Text1.SelText

    End Sub

    Private Sub Command2_Click()

     Text2.SelText = s

End Sub

    2-13

    Private Sub Timer1_Timer()

     If Label1.Top > -Label1.Height Then

     Label1.Top = Label1.Top - 100

     Else

     Label1.Top = Form1.Height

     End If

    End Sub

    3-2

    Private Sub Form_Click()

     Dim n As Integer

     Randomize

     n = Int((90 * Rnd) + 10)

     Print n

    End Sub

    3-3

    Private Sub Timer1_Timer()

     Cls

     Print "河南大学环境与规划学院"

     FontSize = Int(71 * Rnd + 10) End Sub

    3-4

    Private Sub Command1_Click()

     n = Text1.Text

     Text2.Text = Hex(Asc(Right(Text1.Text, 1)))

    End Sub

    Private Sub Command2_Click()

     Text1.Text = " "

     Text2.Text = " "

     Text1.SetFocus

    End Sub

    3-5

    Private Sub Command1_Click()

     Dim m As Date

     m = Text1.Text

     n = Date

     Text2.Text = n - m

    End Sub

    Private Sub Command2_Click()

     Text1.Text = ""

     Text2.Text = ""

     Text1.SetFocus

    End Sub

3-6

     Dim b As String

     Dim n As String

     Dim m As String

    Private Sub Command1_Click()

     m = Left(Text1, 1)

     n = Right(Text1, 1)

     b = Mid(Text1, 2, 1)

     Text2.Text = n & b & m

    End Sub

    Private Sub Command2_Click()

     Text1.Text = ""

     Text2.Text = ""

     Text1.SetFocus

    End Sub

    3-7

    Private Sub Form_click()

     r = InputBox("请输入字符")

     Print Left(r, 1) & Mid(r, 3, 1) & Right(r, 1)

    End Sub

    3-8

    Private Sub Timer1_Timer()

     Label1.FontSize = Rnd * 40 + 10

     Label1.BackColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256)

     Label1.ForeColor = QBColor(Int(16 * Rnd))

    End Sub

    3-10

    Private Sub Form_Click()

     r! = InputBox("请输入您的工资:")

     a = r \ 100

     b = (r - 100 * a) \ 50

     c = (r - 100 * a - b * 50) \ 10

     d = (r - 100 * a - b * 50 - c * 10) \ 5

     e = (r - 100 * a - b * 50 - c * 10 - d * 5) \ 2

     f = r - 100 * a - b * 50 - c * 10 - d * 5 - e * 2

     Print "您的工资是:" & r

     Print "100元张数(" & a

     Print "50元张数(" & b

     Print "10元张数(" & c

     Print "5元张数(" & d

     Print "2元张数(" & e

     Print "1元张数(" & f

    End Sub

4-1

    Private Sub Command1_Click()

     Dim p As Single, r As Single, n As Single

     p = Text1

     r = Text2

     n = Text3

     s = p * (1 + r) ^ n

     MsgBox "您的本息是(" & Round(s, 2) End Sub

    4-2

    Private Sub Form_click()

     Dim max As Single, min As Single

     a! = InputBox("请输入第一个实数")

     b! = InputBox("请输入第二个实数")

     If a > b Then

     Print a, b

     Else

     Print b, a

     End If

    End Sub

    4-3

    Private Sub Form_click()

     Cls

     a! = InputBox("请输入年份")

     If a Mod 4 = 0 And a Mod 100 <> 0 & a Mod 400 = 0 Then

     Print "您刚刚输入的年份为闰年!"

     Else

     Print "您刚刚输入的年份不是闰年!"

     End If

    End Sub

    4-4

    Private Sub Form_click()

     a! = InputBox("a=")

     b! = InputBox("b=")

     c! = InputBox("c=")

     d! = b * b - 4 * a * c

     If d >= 0 Then

     m! = (-b + Sqr(d)) / (2 * a)

     n! = (-b - Sqr(d)) / (2 * a)

     Print " X1 = "; m, ",", "X2="; n

     Else

     r = (-b) / (2 * a)

     i = Sqr(Abs(-d)) / (2 * a)

     Print "X1 = "; r & "+" & Abs(i) & "i", ",", "X2 = "; r & "-" & Abs(i) & "i"

     End If

    End Sub

    4-5

    Private Sub Command1_Click()

     Dim x!

     x = Text1

     If x < 60 Then

     Text2 = "重考?"

     ElseIf x < 70 Then

     Text2 = "及格?"

     ElseIf x < 80 Then

     Text2 = "中等?"

     ElseIf x < 90 Then

     Text2 = "良好?"

     Else

     Text2 = "优秀?"

     End If

    End Sub

    Private Sub Command2_Click()

     Text1 = ""

     Text2 = ""

    End Sub

    4-6

    Private Sub Command1_Click()

     Dim x!

     x = Text1

     Select Case x

     Case Is < 60

     Text2 = "重考?"

     Case Is < 70

     Text2 = "及格?"

     Case Is < 80

     Text2 = "中等?"

     Case Is < 90

     Text2 = "良好?"

     Case Else

     Text2 = "优秀?"

     End Select

    End Sub

    Private Sub Command2_Click()

     Text1 = ""

     Text2 = ""

    End Sub

    4-7

     Dim s As String

    Private Sub Form_Click()

     s = InputBox("请输入年龄")

     If s < 30 Then

     Print "您的年龄为"; s, ",", "请参加长跑运动"

     ElseIf s < 40 Then

     Print "您的年龄为"; s, ",", "请参加跳绳运动"

     ElseIf s < 50 Then

     Print "您的年龄为"; s, ",", "请参加竞走运动"

     Else

     Print "的年龄为"; s, ",", "请参加慢跑运动"

     End If

    End Sub

    4-8

    Private Sub Form_Click()

     For n = 2 To 100 Step 2

     Print n;

     If n Mod 20 = 0 Then Print

     Next n

    End Sub

    4-9

    Private Sub Form_click()

     For n = 100 To 1000

     If n Mod 3 = 2 And n Mod 5 = 3 And n Mod 7 = 2 Then Print n;

     Next n

     Print

    End Sub

    4-10

    Private Sub Form_click()

     m = 0: n = 0

     Do

     r% = InputBox("请输入学生成绩")

     m = m + r

     n = n + 1

     Loop Until r = -1

     Print "学生平均成绩="; (m + 1) / (n - 1)

    End Sub

    4-11

    Private Sub Form_click()

     Dim a As Integer

     Dim s As Integer

     a = 1

     Do

     s = s + (-1) ^ (a + 1) * a

     a = a + 1

     Loop Until a > 100

     Print " 1-2+3-4+5-6++99-100="; s

    End Sub

    4-12

    Private Sub Form_Click()

     Dim n As Integer

     Dim m As Integer

     Dim s As Integer

     m% = InputBox("请输入正整数m(m>=1)", "阶乘")

     n% = InputBox("请输入正整数n(n>=m)", "阶乘")

     For m = m To n

     t = 1

     For i = 1 To m

     t = t * i

     Next i

     s = s + t

     Next m

     Print " m!+(m+1)!++n!="; s

    End Sub

    4-13

    Private Sub Form_click()

     Dim a%

     Dim b%

     Dim c%

     For a = 1 To 20

     For b = 1 To 20

     For c = 1 To 20

     If a * a + b * b = c * c Then

     Print a, b, c

     End If

     Next c

     Next b

     Next a

    End Sub

    4-14

    Private Sub Form_click()

     For n = 1 To 500

     For i = 1 To n - 1

     If n Mod i = 0 Then s = s + i

     Next i

     If s = n Then Print i;

     s = 0

     Next n

     Print

    End Sub

    4-15

    Private Sub Form_click()

     Dim i As Integer

     Dim n As Long

     n = 1

     t = 1

     Do While t > 0.00001

     e = e + t

     i = i + 1

     n = n * i

     t = 1 / n

     Loop

     Print "e的近似值是"; e End Sub

    5-2

    Private Sub Form_Click()

     Dim i%, s

     s = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

     For i = 0 To 9

     If s(i) Mod 3 = 0 Then

     Print s(i); i

     Else

     Print ""

     End If

     Next i

     Print

    End Sub

    5-3

    Option Base 1

    Private Sub Command1_Click()

     Dim x()

     x = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

     t = x(1)

     For i = 1 To 9

     x(i) = x(i + 1)

     Print x(i);

     Next

     x(10) = t

     Print x(i)

    End Sub

    Private Sub Command2_Click()

     Dim x()

     x = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

     t = x(10)

     For i = 9 To 1 Step -1

     x(i + 1) = x(i)

     Next i

     x(1) = t

     For i = 1 To 10

     Print x(i);

     Next i

    End Sub

    5-4

    Private Sub Form_Click()

     Dim a(5, 5)

     For i = 1 To 5

     Sum = 0

     For j = 1 To 5

     a(i, j) = Int(Rnd * 51 + 10)

     Sum = Sum + a(i, j)

     Print a(i, j);

     Next j

     Print Sum

     Next i

     Print

     For i = 1 To 5

     For j = 1 To 5

     If i = j Then Print a(i, j);

     Next j

     Next i

     Print

    End Sub

    5-5

    Private Sub Form_Click()

     Dim a() As Integer

     Dim Max As Integer, iMax As Integer, jMax As Integer

     Dim Min As Integer, iMin As Integer, jMin As Integer

     M = InputBox("输入M")

     N = InputBox("输入N")

     ReDim a(M, N)

     For i = 1 To M

     For j = 1 To N

     a(i, j) = Int(Rnd * 900) + 100

     Next j

     Next i

Report this document

For any questions or suggestions please email
cust-service@docsford.com