Thứ Tư, 12 tháng 6, 2013
so chia het cho 3
Private Sub Command1_Click()
Dim n As Long
n = Text1.Text
If n Mod 3 = 0 Then
MsgBox n & " chia het cho 3"
ElseIf n Mod 3 = 1 Then
MsgBox n & " chia cho 3 du 1"
ElseIf n Mod 3 = 2 Then
MsgBox n & " chia cho 3 du 2"
End If
End Sub
Private Sub Command2_Click()
Form5.Hide
Form2.Show
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
Thứ Năm, 6 tháng 6, 2013
code usename va password
Private Sub Command1_Click()
If Text1.Text = "cuong" And Text2.Text = "123" Then
MsgBox "ban da dang nhap thanh cong"
Form2.Show
Else
Text1.Text = " "
Text2.Text = " "
MsgBox " vui long nhap lai "
End If
End Sub
Private Sub Command2_Click()
Text1.Text = " "
Text2.Text = " "
Form1.Hide
End Sub
Thứ Ba, 4 tháng 6, 2013
Code pha mau
Private Sub VScroll1_Change(Index As Integer)
Dim A As String
With Picture1
.BackColor = RGB(VScroll1(0), VScroll1(1), VScroll1(2))
End With
A = "picture1.backcolor = RGB(" & VScroll1(0).Value & "," & VScroll1(1).Value & "," & VScroll1(2).Value & ","
Label1.Caption = A
End Sub
Thứ Sáu, 31 tháng 5, 2013
code Chạy chữ liên tục
Dim c As String, i, j As Integer
Private Sub Form_Load()
Label1.Caption = " CHUC MUNG NAM MOI "
Label1.FontSize = 40
Label1.Font = vntimeH
c = Label1.Caption
i = 1
HScroll1.Min = 15
HScroll1.Max = 72
j = HScroll1.Min
End Sub
Private Sub HScroll1_Change()
Label1.FontSize = HScroll1
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Mid(Label1.Caption, 2, Len(c)) & Left(Label1.Caption, 1)
If i = 1 Then Label1.ForeColor = vbRed
If i = 2 Then Label1.ForeColor = vbYellow
If i = 3 Then Label1.ForeColor = vbGreen
If i = 4 Then Label1.ForeColor = vbBlue
If i = 5 Then Label1.ForeColor = vborange
If i = 6 Then Label1.ForeColor = &H80000013
If i = 7 Then Label1.ForeColor = &H80000010
If i = 8 Then Label1.ForeColor = &H80000001
If i = 9 Then Label1.ForeColor = vbpink
If i = 10 Then Label1.ForeColor = vbpurple
i = 1
If j < HScroll1.Max Then Label1.FontSize = HScroll1
HScroll1 = j
j = j + 1
End Sub
Thứ Hai, 27 tháng 5, 2013
code đoạn ký tự chạy
Dim c As String, i As Integer
Private Sub Command1_Click()
Form1.Hide
Form2.Show
End Sub
Private Sub Form_Load()
Label1.Caption = "chao mung ban den lop tmdt 6a "
Label1.FontSize = 30
c = Label1.Caption
i = 1
End Sub
Private Sub Timer1_Timer()
If i < Len(c) Then Label1.Caption = Left(c, i)
i = i + 1
End Sub
Chủ Nhật, 26 tháng 5, 2013
code listbox cộng trừ nhân chia
Private Sub Command1_Click()
If list1llistindex = 0 Then Text3.Text = Val(Text1.Text) + Val(Text2.Text)
If list1llistindex = 1 Then Text3.Text = Val(Text1.Text) - Val(Text2.Text)
If list1llistindex = 2 Then Text3.Text = Val(Text1.Text) * Val(Text2.Text)
If list1llistindex = 3 Then Text3.Text = Val(Text1.Text) / Val(Text2.Text)
If list1llistindex = 4 Then Text3.Text = Val(Text1.Text) Mod Val(Text2.Text)
End Sub
Private Sub Command2_Click()
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
End Sub
Private Sub Form_Load()
List1.AddItem "+", 0
List1.AddItem "-", 1
List1.AddItem "*", 2
List1.AddItem "/", 3
List1.AddItem "Mod", 4
End Sub
Thứ Sáu, 24 tháng 5, 2013
Code Tính Tổng N Số Nguyên Dương Đầu Tiên
Private Sub Command1_Click()
Dim i, n As Integer
Dim S As Long
'nhap so nguyen duong n
n = Text1.Text
S = 0
For i = 1 To n
S = S + i
Next
'tong cua n so nguyen duong dau tien
Text2.Text = S
End Sub
Thứ Năm, 16 tháng 5, 2013
Code đọc số nguyên dương có 3 chữ số
Private Sub Command1_Click()
Dim a As String, b As String, c As String
Dim dv As Integer, chuc As Integer, tram As Integer
tram = Text1.Text \ 100
chuc = (Text1.Text Mod 100) \ 10
dv = (Text1.Text Mod 100) Mod 10
Select Case tram
Case 0
a = " "
Case 1
a = " Mét tr¨m "
Case 2
a = " Hai tr¨m "
Case 3
a = " Ba tr¨m "
Case 4
a = " Bèn tr¨m "
Case 5
a = " N¨m tr¨m "
Case 6
a = " S¸u tr¨m "
Case 7
a = " B¶y tr¨m "
Case 8
a = " T¸m tr¨m "
Case 9
a = " ChÝn tr¨m "
End Select
Select Case chuc
Case 0
If tram = 0 Then
b = ""
ElseIf tram <> 0 And dv = 0 Then
b = ""
Else
b = "linh "
End If
Case 1
b = "mêi "
Case 2
b = "hai m¬i "
Case 3
b = "ba m¬i "
Case 4
b = "bèn m¬i "
Case 5
b = "n¨m m¬i "
Case 6
b = "s¸u m¬i "
Case 7
b = "b¶y m¬i "
Case 8
b = "t¸m m¬i "
Case 9
b = "chÝn m¬i "
End Select
Select Case dv
Case 0
c = ""
Case 1
If chuc = 0 Or chuc = 1 Then
c = "mét"
Else
c = "mèt"
End If
Case 2
c = "hai"
Case 3
c = "ba"
Case 4
c = "bèn"
Case 5
c = "n¨m"
Case 6
c = "s¸u"
Case 7
c = "b¶y"
Case 8
c = "t¸m"
Case 9
c = "chÝn"
End Select
Label2.Caption = a & b & c
End Sub
Private Sub Command2_Click()
Text1.Text = " "
Label2.Caption = " "
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
Code giải phương trình bậc 2
Private Sub Command1_Click()
Dim d As Single
d = b * b - 4 * a * c
If a = 0 Then
MsgBox ("PT co nghiem duy nhat ")
Text1.Text = -c / b
Else
If d < 0 Then
MsgBox (" PT vo nghiem")
ElseIf d = 0 Then
MsgBox ("PT co nghiem kep")
Text1.Text = -b / (2 * a)
Text2.Text = -b / (2 * a)
Else
MsgBox (" PT co 2 nghiem phan biet ")
Text1.Text = -b + Sqr(d) / 2 * a
Text2.Text = -b - Sqr(d) / 2 * a
End If
End If
End Sub
Private Sub Command2_Click()
a = " "
b = " "
c = " "
Text1.Text = " "
Text2.Text = " "
End Sub
Private Sub a_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
Private Sub b_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
Private Sub c_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
Thứ Ba, 14 tháng 5, 2013
code tính tuổi theo năm sinh của bạn
Private Sub Command1_Click()
Dim a As Byte, b As Byte, can As String, chi As String
a = Text1.Text Mod 10
b = Text1.Text Mod 12
Select Case a
Case 0
can = "Canh"
Case 1
can = "T©n"
Case 2
can = "Nh©m"
Case 3
can = "Quý"
Case 4
can = "Gi¸p"
Case 5
can = "Êt"
Case 6
can = "BÝnh"
Case 7
can = "§inh"
Case 8
can = "MËu"
Case 9
can = "Kû"
End Select
Select Case b
Case 0
chi = "Th©n"
Case 1
chi = "DËu"
Case 2
chi = "TuÊt"
Case 3
chi = "Hîi"
Case 4
chi = "Tý"
Case 5
chi = "Söu"
Case 6
chi = "DÇn"
Case 7
chi = "M·o"
Case 8
chi = "Th×n"
Case 9
chi = "Tþ"
Case 10
chi = "Ngä"
Case 11
chi = "Mïi"
End Select
Label2.Caption = "B¹n tuæi " & " " & can & " " & chi
End Sub
Thứ Năm, 9 tháng 5, 2013
Code so sánh Max Min
Private Sub Command1_Click()
Dim a As Long, b As Long, c As Long, LN As Long, NN As Long
a = Text1.Text
b = Text2.Text
c = Text3.Text
If a >= b Then
LN = a
NN = b
If c >= LN Then LN = c
If c <= NN Then NN = c
Text4.Text = LN
Text5.Text = NN
Else
LN = b
NN = a
If c >= LN Then LN = c
If c <= NN Then NN = c
Text4.Text = LN
Text5.Text = NN
End If
End Sub
Private Sub Command2_Click()
Text4.Text = " "
Text5.Text = " "
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
' ma Ascii cua 0 la 48, cua 9 la 57
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
' ma Ascii cua 0 la 48, cua 9 la 57
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
' ma Ascii cua 0 la 48, cua 9 la 57
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
code thiết kế lựa chọn check va option
de bai
thiet ke luc chon check va option )
Private Sub Check1_Click()
If Check1.Value = 1 Then
Label1.FontBold = True
Check4.Value = 0
Else
Check1.Value = 0
Label1.FontBold = False
End If
End Sub
Private Sub Check2_Click()
If Check2.Value = 1 Then
Label1.FontItalic = True
Check4.Value = 0
Else
Check1.Value = 0
Label1.FontItalic = False
End If
End Sub
Private Sub Check3_Click()
If Check3.Value = 1 Then
Label1.FontUnderline = True
Check4.Value = 0
Else
Check1.Value = 0
Label1.FontUnderline = False
End If
End Sub
Private Sub Check4_Click()
If Check4.Value = 1 Then
Check1.Value = 0
Check2.Value = 0
Check3.Value = 0
Label1.FontBold = False
Label1.FontItalic = False
Label1.FontUnderline = False
End If
End Sub
Private Sub Option1_Click()
If Option1.Value = True Then
Label1.ForeColor = vbRed
End If
End Sub
Private Sub Option2_Click()
If Option2.Value = True Then
Label1.ForeColor = &H8000000D
End If
End Sub
Private Sub Option3_Click()
If Option3.Value = True Then
Label1.ForeColor = vbYellow
End If
End Sub
Private Sub Option4_Click()
If Option4.Value = True Then
Label1.ForeColor = &H80000012
End If
End Sub
Kiem tra số chẵn số lẻ
" de bai " kiem tra so la so chan hay so le
Private Sub Command1_Click()
Dim n As Integer
n = Text1.Text
If n Mod 2 = 1 Then
MsgBox ("so " & Text1.Text & " la so le ")
Text1.Text = " "
Else
MsgBox ("so " & Text1.Text & " la so chan ")
Text1.Text = " "
End If
End Sub
Tính tổng 2 số
code " tinh tong 2 so "
Private Sub Command1_Click()
Dim a As Long, b As Long, c As Long
a = Text1.Text
b = Text2.Text
c = a + b
Text3.Text = c
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
Đăng ký:
Bài đăng (Atom)