因吐槽而死吧 关注:16贴子:763
  • 2回复贴,共1
Private Sub Command1_Click()
Dim a As Single
Dim b As Single
Dim min As Single
Dim max As Single
a = Val(InputBox("a="))
b = Val(InputBox("b="))
If a > b Then
max = a
min = b
Else
max = b
min = a
End If
Text1.Text = "从小到大是:" + Str(min) + "," + Str(max)
End Sub Private Sub Command2_Click()
Dim x As Single
Dim y As Single
Dim ch As String
x = InputBox("x=")
y = InputBox("y=")
If Sqr(x ^ 2 + y ^ 2) > 2 Then
ch = "NO"
Else
ch = "YES"
End If
Text2.Text = ch End Sub
Private Sub Command3_Click()
a = InputBox("a=")
If a >= 0 And a < 128 Then
Text3.Text = Chr(a)
Else
Text3.Text = Asc(a)
End If End Sub Private Sub Command4_Click()
Dim x As Single
Dim y As Single
x = InputBox("x=")
If x < 0 Then
y = -x + 1
Else
If x = 0 Then
y = 1
Else
y = x + 1
End If
End If
Text4.Text = Str(y) End Sub Private Sub Command5_Click()
Dim s As Single
Dim x As Single
s = InputBox("s=")
If s < 60 Then
x = "不及格"
Else
If s > 90 Then
x = "优秀"
Else
x = "及格"
End If
End If
Text5.Text = "成绩为" & x End Sub Private Sub Command6_Click()
Dim w As Single
Dim m As Single
w = Val(inpytbox("w="))
If w <= 50 Then
Money = 80 * w
Else
If w < 100 Then
m = 50 * 80 + (w - 50) * 75
Else
m = 50 * 80 + 50 * 75 + (w - 100) * 70
End If
End If
Text6.Text = "运费为:" & Str(m) End Sub Private Sub Command7_Click()
Dim a As Single
Dim b As Single
Dim c As Single
Dim dt As Single
Dim x1 As Single
Dim x2 As Single
a = Val(InputBox("a="))
b = Val(InputBox("b="))
c = Val(InputBox("c="))
dt = b ^ 2 - 4 * a * c
If dt > 0 Then
x1 = Int(100 * ((-b + Sqr(dt)) / (2 * a))) / 100
x2 = Int(100 * ((-b + Sqr(dt)) / (2 * a))) / 100
ch = "x1=" & Str(x1) & "x2=" & Str(x2)
Else
If dt = 0 Then
x1 = Int(100 * (-b / (2 * a))) / 100
ch = "x1=x2=" & Str(x1)
Else
ch = "无实数解"
End If
End If
End If End Sub Private Sub Command8_Click()
Dim a As Single
Dim ch As String
a = Val(InputBox("a="))
If a = 1 Then
ch = "星期一"
End If
If a = 1 Then
ch = "星期一"
End If
a = Val(InputBox("a="))
If a = 1 Then
ch = "星期一"
End If
If a = 1 Then
ch = "星期一"
End If
a = Val(InputBox("a="))
If a = 1 Then
ch = "星期一"
End If
If a = 1 Then
ch = "星期一"
End If
If a = 1 Then
ch = "星期一"
End If
End Sub


1楼2013-02-26 12:03回复
    Private Sub Command7_Click()
    Dim n As Integer, flag As Integer, s As Integer
    n = Val(InputBox("n="))
    flag = 1
    For i = 2 To n - 1 Step 1
    If n Mod i = 0 Then
    flag = 0
    End If
    Next i
    Text7.Text = "flag=" + Str(flag)
    End Sub Private Sub Command8_Click()
    Dim i As Integer
    If x > 0 Then
    i = 1
    Do While i < 5
    i = i + 1
    x = x * i
    Loop
    End If
    If x > 0 Then
    For i = 2 To 5 Step 1
    x = x * i
    Next i
    End If
    Text8.Text = "s=" + Str(s)
    End Sub


    5楼2013-03-14 14:29
    回复
      Private Sub Command10_Click()
      Dim n As Integer
      n = Val(InputBox("n="))
      n = n - 1
      s = 1 - 1 / (n + 1)
      Text10.Text = "s=" + Str(s)
      End Sub


      7楼2013-03-14 14:39
      回复