TA lop 8
Chia sẻ bởi Trần Lý Hoàng Thiện |
Ngày 10/10/2018 |
36
Chia sẻ tài liệu: TA lop 8 thuộc Tiếng Anh 6
Nội dung tài liệu:
CÁC CODE TRONG PHẦN BÀI THI THỰC HÀNH
Bài 1:
Private Sub cmdTinh_Click()
If Not IsNumeric(txtDai.Text) Then
MsgBox "Nhap chieu dai!"
txtDai.SetFocus
ElseIf Not IsNumeric(txtRong.Text) Then
MsgBox "Nhap chieu rong!"
txtRong.SetFocus
ElseIf Not IsNumeric(txtCao.Text) Then
MsgBox "Nhap chieu cao!"
txtCao.SetFocus
Else
txtThetich.Text = Val(txtDai.Text) * Val(txtRong.Text) * Val(txtCao.Text)
End If
End Sub
Bài 2:
Private Sub cmdTinh_Click()
Const pi = 3.14159
Dim r As Single
Dim dt As Single
If Not IsNumeric(txtDai.Text) Then
MsgBox "Nhap chieu dai!"
txtDai.SetFocus
ElseIf Not IsNumeric(txtChuvi.Text) Then
MsgBox "Nhap chu vi!"
txtChuvi.SetFocus
Else
r = Val(txtChuvi.Text) / (2 * pi)
dt = pi * r * r
txtThetich.Text = dt * Val(Me.txtDai.Text)
End If
End Sub
Bài 3:
Private Sub cmdGiai_Click()
Dim delta As Single
Dim a As Single
Dim b As Single
Dim c As Single
If Val(Me.txtHSa.Text) = 0 Then
MsgBox "He so a khong dung!"
txtHSa.SetFocus
ElseIf Not IsNumeric(txtHSa.Text) Then
MsgBox "Nhap he so b!"
txtHSb.SetFocus
ElseIf Not IsNumeric(txtHSc.Text) Then
MsgBox "Nhap he so c!"
txtHSc.SetFocus
Else
LstKetqua.Clear
a = Val(txtHSa.Text)
b = Val(txtHSb.Text)
c = Val(txtHSc.Text)
delta = b * b - 4 * a * b * c
If delta < 0 Then
LstKetqua.AddItem ("VO NGHIEM")
ElseIf delta = 0 Then
LstKetqua.AddItem ("x1=x2=" & CStr(-b / (2 * a)))
Else
LstKetqua.AddItem ("x1=" & CStr((-b - Sqr(delta)) / (2 * a)))
LstKetqua.AddItem ("x2=" & CStr((-b + Sqr(delta)) / (2 * a)))
End If
End If
End Sub
Bài 4:
Private Sub Cmdoqua_Click()
If MsgBox("Dong y thoat?", vbYesNo + vbQuestion, "Hoi!") = vbYes Then End
End Sub
Public Function SapXiep(ByVal blTang As Boolean, ByVal strNhap As String) As String
Dim i, j As Integer
Dim temp As Long
Dim StrTemp As String
Dim m
m = Split(Trim(strNhap), " ")
If blTang Then
For i = 0 To UBound(m) - 1
For j = 0 To UBound(m) - i - 1
If Val(Trim(m(j))) > Val(Trim(m(j + 1))) Then
temp = Val(Trim(m(j)))
m(j) = Val(Trim(m(j + 1)))
m(j + 1) = temp
End If
Next j
Next i
Else
For i = 0 To UBound(m) - 1
For j = 0 To UBound(m) - i - 1
If Val(Trim(m(j))) < Val(Trim(m(j + 1))) Then
temp = Val(Trim(m(j)))
m(j) = Val(Trim(m(j + 1)))
m(j + 1) = temp
End If
Next j
Next i
End If
For i = 0 To UBound(m)
StrTemp = StrTemp & m(i) & " "
Next i
SapXiep = StrTemp
End Function
Private Sub cmdSapso_Click()
If Trim(Me.TxtSoNhap.Text) = "" Then
MsgBox "Nhap day so can sap xiep"
Me.TxtSoNhap.SetFocus
Exit Sub
End If
If Me.OptTang.Value Then
Me.TxtXuat.Text = SapXiep(True, Me.TxtSoNhap.Text)
Else
Me.TxtXuat.Text = SapXiep(False, Me.TxtSoNhap.Text)
End If
End Sub
Private Sub Form_Load()
Me.lblNgay.Caption = Now
End Sub
Private Sub TmrThoiGian_Timer()
Me.lblNgay.Caption = Now
End Sub
Private Sub TxtSoNhap_GotFocus
Bài 1:
Private Sub cmdTinh_Click()
If Not IsNumeric(txtDai.Text) Then
MsgBox "Nhap chieu dai!"
txtDai.SetFocus
ElseIf Not IsNumeric(txtRong.Text) Then
MsgBox "Nhap chieu rong!"
txtRong.SetFocus
ElseIf Not IsNumeric(txtCao.Text) Then
MsgBox "Nhap chieu cao!"
txtCao.SetFocus
Else
txtThetich.Text = Val(txtDai.Text) * Val(txtRong.Text) * Val(txtCao.Text)
End If
End Sub
Bài 2:
Private Sub cmdTinh_Click()
Const pi = 3.14159
Dim r As Single
Dim dt As Single
If Not IsNumeric(txtDai.Text) Then
MsgBox "Nhap chieu dai!"
txtDai.SetFocus
ElseIf Not IsNumeric(txtChuvi.Text) Then
MsgBox "Nhap chu vi!"
txtChuvi.SetFocus
Else
r = Val(txtChuvi.Text) / (2 * pi)
dt = pi * r * r
txtThetich.Text = dt * Val(Me.txtDai.Text)
End If
End Sub
Bài 3:
Private Sub cmdGiai_Click()
Dim delta As Single
Dim a As Single
Dim b As Single
Dim c As Single
If Val(Me.txtHSa.Text) = 0 Then
MsgBox "He so a khong dung!"
txtHSa.SetFocus
ElseIf Not IsNumeric(txtHSa.Text) Then
MsgBox "Nhap he so b!"
txtHSb.SetFocus
ElseIf Not IsNumeric(txtHSc.Text) Then
MsgBox "Nhap he so c!"
txtHSc.SetFocus
Else
LstKetqua.Clear
a = Val(txtHSa.Text)
b = Val(txtHSb.Text)
c = Val(txtHSc.Text)
delta = b * b - 4 * a * b * c
If delta < 0 Then
LstKetqua.AddItem ("VO NGHIEM")
ElseIf delta = 0 Then
LstKetqua.AddItem ("x1=x2=" & CStr(-b / (2 * a)))
Else
LstKetqua.AddItem ("x1=" & CStr((-b - Sqr(delta)) / (2 * a)))
LstKetqua.AddItem ("x2=" & CStr((-b + Sqr(delta)) / (2 * a)))
End If
End If
End Sub
Bài 4:
Private Sub Cmdoqua_Click()
If MsgBox("Dong y thoat?", vbYesNo + vbQuestion, "Hoi!") = vbYes Then End
End Sub
Public Function SapXiep(ByVal blTang As Boolean, ByVal strNhap As String) As String
Dim i, j As Integer
Dim temp As Long
Dim StrTemp As String
Dim m
m = Split(Trim(strNhap), " ")
If blTang Then
For i = 0 To UBound(m) - 1
For j = 0 To UBound(m) - i - 1
If Val(Trim(m(j))) > Val(Trim(m(j + 1))) Then
temp = Val(Trim(m(j)))
m(j) = Val(Trim(m(j + 1)))
m(j + 1) = temp
End If
Next j
Next i
Else
For i = 0 To UBound(m) - 1
For j = 0 To UBound(m) - i - 1
If Val(Trim(m(j))) < Val(Trim(m(j + 1))) Then
temp = Val(Trim(m(j)))
m(j) = Val(Trim(m(j + 1)))
m(j + 1) = temp
End If
Next j
Next i
End If
For i = 0 To UBound(m)
StrTemp = StrTemp & m(i) & " "
Next i
SapXiep = StrTemp
End Function
Private Sub cmdSapso_Click()
If Trim(Me.TxtSoNhap.Text) = "" Then
MsgBox "Nhap day so can sap xiep"
Me.TxtSoNhap.SetFocus
Exit Sub
End If
If Me.OptTang.Value Then
Me.TxtXuat.Text = SapXiep(True, Me.TxtSoNhap.Text)
Else
Me.TxtXuat.Text = SapXiep(False, Me.TxtSoNhap.Text)
End If
End Sub
Private Sub Form_Load()
Me.lblNgay.Caption = Now
End Sub
Private Sub TmrThoiGian_Timer()
Me.lblNgay.Caption = Now
End Sub
Private Sub TxtSoNhap_GotFocus
* Một số tài liệu cũ có thể bị lỗi font khi hiển thị do dùng bộ mã không phải Unikey ...
Người chia sẻ: Trần Lý Hoàng Thiện
Dung lượng: 55,50KB|
Lượt tài: 0
Loại file: doc
Nguồn : Chưa rõ
(Tài liệu chưa được thẩm định)