Thủ thuật: Khóa File ảnh có định dạng .BMP
Tác giả: Sưu tầmMô tả: Hướng dẫn Khóa File ảnh có định dạng .BMP
Đầu tiên các bạn chuẩn bị :
- 3 Command tên lần lượt là Command1,Command2,Command3
- 1 Text tên là Text1
- 1 CommonDialog1 tên là CommonDialog1
Ở phần Form_Load các bạn thêm code sau :
Private Sub Form_Load()
Command1.Caption = "khoa file anh"
Command2.Caption = "Mo file anh"
End Sub
Để có thể Khóa ảnh các bạn thêm code sau :
Function MoKhoa(File)
A = FreeFile
Open File For Binary As #A
B$ = Chr(0)
Put #A, 17, B$
Close #A
End Function
Function KhoaAnh(File)
A = FreeFile
Open File For Binary As #A
B$ = "X"
Put #A, 17, B$
Close #A
End Function
Và phần còn lại là thêm code sau cho Command 1 2 3:
Private Sub Command1_Click()
KhoaAnh Text1.Text
End Sub
Private Sub Command2_Click()
MoKhoa Text1.Text
End Sub
Private Sub Command3_Click()
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
End Sub
Nếu các bạn sợ không đúng thì coppy toàn bộ code sau :
Function MoKhoa(File)
A = FreeFile
Open File For Binary As #A
B$ = Chr(0)
Put #A, 17, B$
Close #A
End Function
Function KhoaAnh(File)
A = FreeFile
Open File For Binary As #A
B$ = "X"
Put #A, 17, B$
Close #A
End Function
Private Sub Command1_Click()
KhoaAnh Text1.Text
End Sub
Private Sub Command2_Click()
MoKhoa Text1.Text
End Sub
Private Sub Command3_Click()
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
End Sub
Private Sub Form_Load()
Command1.Caption = "khoa file anh"
Command2.Caption = "Mo file anh"
End Sub
Vậy là xong !
