1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Bài tập kỹ thuật lập trình docx

24 473 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 24
Dung lượng 842 KB

Nội dung

Bài 1. viết chương trình lời chào hello!!! Private Sub cmdCHAO_Click() txtDisplay.Text = "chao ban!!!!!" End Sub Private Sub cmdTHOAT_Click() End End Sub Private Sub cmdXOA_Click() txtDisplay.Text = "" End Sub Bài 2 Option Explicit Private Sub cmdCAPNHAT_Click() Dim GT As String * 5 Dim HOTEN As String * 30 Dim NAMSINH As Integer Dim TUOI As Single Dim NAM As Date 'gán giá tri vào bien HOTEN = txtHOTEN NAMSINH = Val(txtNAMSINH) NAM = Year(Date) TUOI = NAM - txtNAMSINH If chkGT = 1 Then If TUOI <= 25 Then GT = " ANH " Else If TUOI > 50 Then GT = " ONG " Else GT = " CHU " End If End If Else If TUOI <= 25 Then GT = " CHI " Else If TUOI > 50 Then GT = " BA " Else GT = " CO " End If End If End If lblCHAO = "Chào" & GT & HOTEN & Chr(13) & "Rất vui được đón" & GT & "đến với cửa hàng của chúng tôi" End Sub Private Sub cmdTHOAT_Click() End End Sub Bài 3 Private Sub CmdASCII_Click() Dim i As Integer For i = 0 To 255 Text2 = Text2 & vbCrLf & i & " >" & Chr(i) Next i End Sub Private Sub CmdTHOAT_Click() End End Sub Private Sub CmdTINH_Click() LblKQ = Text1 & " >" & Chr(Text1) End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Text1.SetFocus Text1.SelStart = 0 Text1.SelLength = Len(Text1) LblKQ = "ki tu bieu dien cua ma ASCII" & Text1 & " la: " & Chr(Val(Text1)) End If End Sub Bài 4 Private Sub CMDTHOAT_Click() If MsgBox("Ban That Su Muon Thoat??", 4 + 32, "tb") = 6 Then End End If End Sub Private Sub CMDXEM_Click() Dim I As Byte Dim A As String TXTNHAP.SetFocus If I < 1 And I > 9 Then TXT2.Text = "KHONG CO KET QUA!!!" TXTNHAP.SetFocus TXTNHAP.SelStart = 0 TXTNHAP.SelLength = Len(TXTNHAP) Else For I = 1 To 10 A = TXTNHAP.Text * I TXT2.Text = TXT2 & vbCrLf & TXTNHAP & " X " & I & " = " & A & vbCrLf TXTNHAP.SetFocus TXTNHAP.SelStart = 0 TXTNHAP.SelLength = Len(TXTNHAP) TXT2.SelStart = 0 TXT2.SelLength = Len(TXT2) Next I End If End Sub Bài 5 Private Sub cmdthoat_Click(Index As Integer) End End Sub Private Sub cmdtinh_Click(Index As Integer) Dim N, I, GT, X, f As Integer Dim S, T, S2, S3, S4 As Single N = Val(txt1) S = 0 For I = 1 To N S = S + 1 / I S = Format(S, "##,##.00") txt3 = S Next I GT = 1 T = 0 For I = 1 To N GT = GT * I T = T + 1 / GT T = Format(T, "##,##.00") txt4 = T Next I GT = 1 X = Val(txt2) S2 = 1 For I = 1 To N G = G * I S2 = S2 + X * I / GT txt5 = S2 Next I S4 = 0 For I = 1 To N S4 = S4 + Sin(X) + Sin(X) * I txt7 = S4 Next I End Sub Bài 6 Option Explicit Dim i As Byte Private Sub Form_Load() i = 0 End Sub Private Sub Timer1_Timer() If i < 5 Then Me.BackColor = QBColor(Int(Rnd * 16)) Image1.Picture = Image2(i).Picture i = i + 1 Else i = 0 End If End Sub Bài 7 Private Sub cmd_thoat_Click() End End Sub Private Sub cmd1_Click() Dim X, Y, CANH, CANH2 As Single X = Val(txtX) Y = Val(txtY) CANH = Val(txtCANH) CANH2 = Val(txtCANH2) If (txtCANH2.Visible = True) Then Shape1.Left = X Shape1.Top = Y Shape1.Width = CANH2 Shape1.Height = CANH Else Shape1.Left = X Shape1.Top = Y Shape1.Width = CANH Shape1.Height = CANH End If End Sub Private Sub cmd2_Click() Dim X, Y, CANH As Single X = Val(txtX) Y = Val(txtY) CANH = Val(txtCANH) CANH2 = Val(txtCANH2) If (txtCANH2.Visible = True) Then Shape1.Left = X - CANH / 2 Shape1.Top = Y - CANH2 / 2 Shape1.Width = CANH2 Shape1.Height = CANH Else Shape1.Left = X - CANH / 2 Shape1.Top = Y - CANH / 2 Shape1.Width = CANH Shape1.Height = CANH End If End Sub Private Sub form_load() ScaleMode = 7 Picture1.ScaleMode = 7 End Sub Private Sub Option2_Click(Index As Integer) Shape1.Shape = Index Select Case Index Case 0, 2 Label4.Visible = True txtCANH2.Visible = True Case 1, 3 Label4.Visible = False txtCANH2.Visible = False End Select End Sub Bài 8 timer : intetval: 500 Private Sub Timer1_Timer() Label1 = Time() End Sub Bài 9 [...]... Chr(13) & "hieu= " & hieu & Chr(13) & "tich= " & tich & Chr(13) & "thuong= " & thuong txtsodau.SetFocus txtsodau.SelStart = 0 txtsodau.SelLength = Len(txtsodau) End Sub Bài 11 Private Sub Command1_Click() lblxuat = txtnhap End Sub Bài 12 USCLN FORM 1 Option Explicit Dim x As Byte Dim y As Byte Public Function USCLN(ByVal A As Integer, ByVal B As Integer) Dim r As Integer Do While B 0 r = A Mod B... txtCanh2.SelStart = 0 txtCanh2.SelLength = Len(txtCanh2) End If End Sub Private Sub txtCanh2_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then ' goi thuc hien thu tuc cmdTINH-click cmdTINH_Click End If End Sub Bài 10 Private Sub cmdthoat_Click() End End Sub Private Sub txtsodau_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtsosau.SetFocus txtsosau.SelStart = 0 txtsosau.SelLength = Len(txtsosau) End If... Integer soA = Val(txtA) soB = Val(txtB) lblKQ = "uoc so chung lon nhat = " & Form1.USCLN(soA, soB) End Sub Private Sub Command2_Click() 'giải phóng for khỏi bộ nhớ Unload Me 'hiện form Form1.Show End Sub Bài 13.List Option Explicit Private Sub cmdEnd_Click() End End Sub Private Sub cmdSUA_Click() If txtNAME = "" Then MsgBox "chua nhap" txtNAME.SetFocus Else lstDS.List(lstDS.ListIndex) = txtNAME End If... lstDS.ListCount End Sub Private Sub Form_Load() Label3 = lstDS.ListCount cmdXOA.Enabled = False End Sub Private Sub lstDS_Click() txtNAME.Text = lstDS.Text cmdXOA.Enabled = True txtNAME.SetFocus End Sub Bài 14 Chạy chữ Option Explicit Private Sub Timer1_Timer() lblTRAI = Right(lblTRAI, Len(lblTRAI) - 1) & Left(lblTRAI, 1) lblTRAI.ForeColor = QBColor(Int(Rnd * 16)) lblPHAI = Right(lblPHAI, 1) & Left(lblPHAI,... HsbColor(Index).Value = Val(txtColor(Index).Text) 'Đặt màu tô của shpSample bằng RGB của ba giá trò trong ba thanh cuộn shpSample.FillColor = RGB(HsbColor(0).Value, HsbColor(1).Value, HsbColor(2).Value) End Sub Bài 15 Điều kiện hình vng và dãy hình vng Private Sub cmd_cheo_Click() Dim X, Y, CANH As Single X = Val(txtX) Y = Val(txtY) CANH = Val(txtCANH) Shape1.Left = X Shape1.Top = Y Shape1.Width = CANH Shape1.Height... Sqr(CANH * CANH + CANH * CANH) Picture1.Line (X, Y)-(X + CANH, Y + CANH) Picture1.Line (X + CANH, Y)-(X, Y + CANH) End Sub Private Sub Timer1_Timer() Shape1.BackColor = QBColor(Int(Rnd * 16)) End Sub Bài 16 Diện tích, chu vi hcn Option Explicit Private Sub cmdTINH_Click() Dim CANH1, CANH2, DT, CV As Single CANH1 = Val(txtCanh1) CANH2 = Val(txtCanh2) CV = (CANH1 + CANH2) * 2 DT = CANH1 * CANH2 lblKQ... txtCanh2.SelStart = 0 txtCanh2.SelLength = Len(txtCanh2) End If End Sub Private Sub txtCanh2_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then ' goi thuc hien thu tuc cmdTINH-click cmdTINH_Click End If End Sub Bài 17 Private Sub cmdco_GotFocus() cmdco.SetFocus End Sub Private Sub cmdco_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) cmdco.Move Rnd * (Me.ScaleWidth - cmdco.Width), Rnd . Bài 1. viết chương trình lời chào hello!!! Private Sub cmdCHAO_Click() txtDisplay.Text = "chao ban!!!!!" End. 3 Label4.Visible = False txtCANH2.Visible = False End Select End Sub Bài 8 timer : intetval: 500 Private Sub Timer1_Timer() Label1 = Time() End Sub Bài 9 Option Explicit Private Sub cmdTINH_Click() Dim CANH1,. thuong txtsodau.SetFocus txtsodau.SelStart = 0 txtsodau.SelLength = Len(txtsodau) End Sub Bài 11 Private Sub Command1_Click() lblxuat = txtnhap End Sub Bài 12 USCLN FORM 1 Option Explicit Dim x As Byte Dim y As Byte Public

Ngày đăng: 12/07/2014, 16:20

TỪ KHÓA LIÊN QUAN

w