If any DateNow Then any DateNow If any

  • Slides: 24
Download presentation

⑴ If any. Date<Now Then any. Date=Now ⑵ If any. Date<Now Then any. Date=Now

⑴ If any. Date<Now Then any. Date=Now ⑵ If any. Date<Now Then any. Date=Now End If ⑤If…Then的单行格式不用End If语句。 例3. 5

§ Private Sub Form_Click() § Dim a As Single, b As Single, c As

§ Private Sub Form_Click() § Dim a As Single, b As Single, c As Single § Dim p As Single, s As Single § Text 1. Text = "" : Text 2. Text = "" : Text 3. Text = "" § a = val(Text 1) : b = val(Text 2) t : c = val(Text 3) t § If a+b>c and b+c>a and a+c>b then § p = (a + b + c) / 2 § s = Sqr(p * (p - a) * (p - b) * (p - c)) § Else § print “它不能构成一个三角形” § End If § End Sub

Private Sub Command 1_Click() Dim score As Integer, temp As String score = Val(Text

Private Sub Command 1_Click() Dim score As Integer, temp As String score = Val(Text 1. Text) temp = "成绩等级为:" If score < 0 Then Label 2. Caption = "成绩出错" Else. If score < 60 Then Label 2. Caption = temp + "不及格" Else. If score <= 79 Then Label 2. Caption = temp + "及格" Else. If score <= 100 Then Label 2. Caption = temp + "优良" Else Label 2. Caption = "成绩出错" End If End Sub

Private Sub Command 1_Click() '“计算”按钮 Dim a As Single, b As Single, t As

Private Sub Command 1_Click() '“计算”按钮 Dim a As Single, b As Single, t As Single, s As String a = Val(Text 1. Text) b = Val(Text 2. Text) Select Case True Private Sub Form_Load() Case Option 1. Value ' + 运算 Option 1. Value = True + 运算 s = "+" End Sub t=a+b Case Option 2. Value ' - 运算 s = "-" t=a-b Private Sub Command 2_Click() Case Option 3. Value ' * 运算 Text 1. Text = "" s = "*" Text 2. Text = "" t=a*b Text 3. Text = "" Case Option 4. Value ' / 运算 End Sub s = "/" t=a/b Private Sub Command 3_Click() End Select Unload Me Text 3. Text = a & s & b & "=" & t End Sub

Private Sub Command 1_Click() Dim a As Single, b As Single, c As Single

Private Sub Command 1_Click() Dim a As Single, b As Single, c As Single Dim D As Single, X 1 As Single, X 2 As Single Dim R As Single, P As Single a = Val(Text 1. Text) '取数据a b = Val(Text 2. Text) '取数据b c = Val(Text 3. Text) '取数据c If a = 0 Then '当a=0 Text 4. Text = "不是二次方程" Text 5. Text = "不是二次方程" Else 'a<>0 D=b*b-4*a*c R = -b / (2 * a)

If D = 0 Then 'D=0 Text 4. Text = R Text 5. Text

If D = 0 Then 'D=0 Text 4. Text = R Text 5. Text = R Else. If D > 0 Then 'D>0 X 1 = (-b + Sqr(D)) / (2 * a) X 2 = (-b - Sqr(D)) / (2 * a) Text 4. Text = X 1 Text 5. Text = X 2 Else 'D<0 P = Sqr(-D) / (2 * a) Text 4. Text = R & "+" & P & "i" Text 5. Text = R & "-" & P & "i" End If End Sub