1. THÔNG BÁO TUYỂN ADMIN DIỄN ĐÀN 2013
    Tìm kiếm nhà trọ - Ở ghép
    THÔNG BÁO BÁN ÁO SPKT.NET CHO THÀNH VIÊN DIỄN ĐÀN


    HÃY TÌM KIẾM Ở ĐÂY TRƯỚC KHI ĐẶT CÂU HỎI
    {xen:phrase loading}

đề thi visual

Thảo luận trong 'Visual Basic' bắt đầu bởi Ngọc Bình, 18 Tháng ba 2011.

  1. Ngọc Bình New Member

    Số bài viết: 61
    Đã được thích: 0
    Điểm thành tích: 0
    Câu 01
    Option Explicit
    Private Sub Form_Load()
    txtA.Text = ""
    txtB.Text = ""
    txtC.Text = ""
    lblKq.Caption = ""
    lblX1.Caption = ""
    lblX2.Caption = ""
    End Sub

    Private Sub cmdGiai_Click()
    Dim a As Double, b As Double, c As Double
    Dim delta As Double, x1 As Double, x2 As Double
    a = Val(txtA.Text)
    b = Val(txtB.Text)
    c = Val(txtC.Text)
    If a = 0 Then
    If b = 0 Then
    If c = 0 Then
    lblKq.Caption = "Phuong trinh bac nhat co vo so nghiem"
    Else
    lblKq.Caption = "Phuong trinh bac nhat vo nghiem"
    End If
    Else
    x1 = -c / b
    lblKq.Caption = "Phuong trinh bac nhat co nghiem"
    lblX1.Caption = Format(x1, "0.00")
    End If
    Else
    delta = b * b - 4 * a * c
    If delta < 0 Then
    lblKq.Caption = "Phuong trinh bac hai vo nghiem"
    Else
    x1 = (-b + Sqr(delta)) / (2 * a)
    x2 = (-b - Sqr(delta)) / (2 * a)
    lblKq.Caption = "Phuong trinh bac hai co nghiem"
    lblX1.Caption = Format(x1, "0.00")
    lblX2.Caption = Format(x2, "0.00")
    End If
    End If
    End Sub

    Câu 2
    Option Explicit
    Private Sub Form_Load()
    txtTp.Text = ""
    txtNp.Text = ""
    End Sub

    Private Sub cmdD2B_Click()
    Dim s As String
    Dim a As Integer, SoDu As Integer
    s = ""
    a = Val(txtTp.Text)
    While a > 0
    SoDu = a Mod 2
    s = LTrim(Str(SoDu)) & s
    a = a \ 2
    Wend
    txtNp.Text = s
    End Sub

    Private Sub cmdB2D_Click()
    Dim s As String, c As String
    Dim L As Integer, i As Integer
    Dim a As Integer, CoSo As Integer
    s = txtNp.Text
    L = Len(s)
    CoSo = 1
    a = 0
    For i = L To 1 Step -1
    c = Mid(s, i, 1)
    a = a + CoSo * Val(c)
    CoSo = CoSo * 2
    Next
    txtTp.Text = LTrim(Str(a))
    End Sub

    Câu 3:
    Option Explicit

    Private Sub Form_Load()
    txtA.Text = ""
    txtB.Text = ""
    lblUsa.Caption = ""
    lblUsb.Caption = ""
    lblUsc.Caption = ""
    lblUscln.Caption = ""
    End Sub

    Private Sub cmdGiai_Click()
    Dim a As Integer, b As Integer
    Dim USA(20) As Integer, USB(20) As Integer, USC(20) As Integer
    Dim USCLN As Integer
    Dim SoLuongUSA As Integer, SoLuongUSB As Integer, SoLuongUSC As Integer
    Dim s As String
    Dim i As Integer, j As Integer, x As Integer

    ' Tinh cac uoc so a
    SoLuongUSA = 0
    a = Val(txtA.Text)
    For i = 1 To a
    If a Mod i = 0 Then
    USA(SoLuongUSA) = i
    SoLuongUSA = SoLuongUSA + 1
    End If
    Next
    s = ""
    For i = 0 To SoLuongUSA - 1
    s = s & Str(USA(i))
    Next
    lblUsa.Caption = s

    ' Tinh cac uoc so b
    SoLuongUSB = 0
    a = Val(txtB.Text)
    For i = 1 To a
    If a Mod i = 0 Then
    USB(SoLuongUSB) = i
    SoLuongUSB = SoLuongUSB + 1
    End If
    Next
    s = ""
    For i = 0 To SoLuongUSB - 1
    s = s & Str(USB(i))
    Next
    lblUsb.Caption = s

    ' Tinh cac uoc so chung
    SoLuongUSC = 0
    For i = 0 To SoLuongUSA - 1
    x = USA(i)
    For j = 0 To SoLuongUSB - 1
    If x = USB(j) Then
    USC(SoLuongUSC) = x
    SoLuongUSC = SoLuongUSC + 1
    Exit For
    End If
    Next
    Next
    s = ""
    For i = 0 To SoLuongUSC - 1
    s = s & Str(USC(i))
    Next
    lblUsc.Caption = s

    ' USCLN
    USCLN = USC(SoLuongUSC - 1)
    lblUscln.Caption = LTrim(Str(USCLN))
    End Sub

    Câu 4

    Option Explicit
    Dim A(20) As Integer
    Dim N As Integer 'N la so luong phan tu cua mang



    Private Sub Form_Load()
    N = 5
    A(0) = 9
    A(1) = 5
    A(2) = 1
    A(3) = 3
    A(4) = 7
    Dim i As Integer
    Dim s As String
    s = ""
    For i = 0 To N - 1
    s = s & Str(A(i))
    Next
    lblMangA.Caption = s
    lblMangB.Caption = ""
    txtX.Text = ""
    lblMangC.Caption = ""
    End Sub

    Private Sub cmdSap_Click()
    Dim i As Integer, j As Integer
    Dim temp As Integer
    Dim s As String
    For i = 0 To N - 2
    For j = i + 1 To N - 1
    If A(i) > A(j) Then
    temp = A(i)
    A(i) = A(j)
    A(j) = temp
    End If
    Next
    Next
    s = ""
    For i = 0 To N - 1
    s = s & Str(A(i))
    Next
    lblMangB.Caption = s
    End Sub

    Private Sub cmdChen_Click()
    Dim x As Integer, i As Integer, j As Integer
    Dim s As String
    x = Val(txtX.Text)
    i = 0

    While x > A(i) And i < N
    i = i + 1
    Wend

    For j = N - 1 To i Step -1
    A(j + 1) = A(j)
    Next
    A(i) = x

    N = N + 1
    s = ""
    For i = 0 To N - 1
    s = s & Str(A(i))
    Next
    lblMangC.Caption = s
    End Sub

    Câu 5
    Option Explicit

    Private Sub cmdTong_Click()
    Dim s As String, c As String, word As String
    Dim L As Integer, i As Integer, B As Integer, E As Integer
    Dim InWord As Boolean
    Dim sum As Double
    s = txtS.Text
    InWord = False
    L = Len(s)
    ' B danh dau dau tu
    ' E danh dau cuoi tu
    sum = 0
    For i = 1 To L
    c = Mid(s, i, 1)
    If Not IsNumeric(c) Then
    If InWord = True Then
    E = i
    word = Mid(s, B, E - B)
    sum = sum + Val(word)
    End If
    InWord = False
    Else
    If InWord = False Then
    B = i
    InWord = True
    End If
    End If
    Next
    If InWord = True Then
    E = L + 1
    word = Mid(s, B, E - B)
    sum = sum + Val(word)
    End If
    lblTong.Caption = LTrim(Str(sum))
    End Sub

    Private Sub Form_Load()
    txtS.Text = ""
    lblTong.Caption = ""
    End Sub
  2. thaiphonght Member

    Số bài viết: 30
    Đã được thích: 0
    Điểm thành tích: 6
  3. giactrantam Member

    Số bài viết: 31
    Đã được thích: 0
    Điểm thành tích: 6
  4. truongvinh Member

    Số bài viết: 32
    Đã được thích: 0
    Điểm thành tích: 6

Chia sẻ trang này