Introduction
If you want to identify your guests and then use the identification card (ID Card) is very convenient. Normally, you use ID Card which means you have a lot of guests. So, we design an ID Card print program to help you print many ID Cards. Otherwise, if you want to make your business card, you should try it. It can preview your design before you want to print.
We use a simple file system to manage our ID Card that means you just arrange to a folder. There are many files in the folder. The file name separates two parts, including number part and name part. You can adjust the count of the number and you will find out the two parts of change such as file name is ‘0001Brian.jpg’ and then the count of the number is four. The number part is ‘0001
’ and the name part is ‘Brian
’. You can make a lot of files for the ID Card or make your business card. You also are able to load foreground and background picture on the ID Card. It is good and beautiful.
We will use an ADO database object, a file system object and a report object. The ADO database object helps us to connect report object that it is able to preview and print ID Card. The file system object arrange and manage temporal files can be used. You can redesign this program to suit your requirements. There are three language editions for you.
Background
Equipment
- Operation System: Microsoft Windows 7 Professional (64 bit)
- Development Utility: Microsoft Visual Basic 6.0
Using the Code
- Initial all objects, especially, a database object and a file system object.
Private Sub Form_Load()
Set objFso = New FileSystemObject
Set objStm = New ADODB.Stream
strLTYD_FN = App.Path & "\db1.mdb"
Call mdiMM_Setup_cnnDB
txtMM_PD.Text = GetSetting("GeneralOffice", "IdentificationCard", _
"PhotosFolder", App.Path & "\IMG")
txtMM_PD.Text = Trim(txtMM_PD.Text)
File1.Path = Trim(txtMM_PD.Text)
Call frmCLASS_Load_imgCLASS_Card_F
Call frmCLASS_Load_imgCLASS_Card_B
End Sub
- How to load a binary file into the field of the Access 2003 database.
Private Sub cmdCLASS_Card_F_Click()
On Error GoTo cmdCLASS_Card_F_Click_ER:
Dim strPT As String
Dim intERR_Count As Integer
strPT = App.Path & "LTY-PicTmp.WOK"
If Right$(App.Path, 1) <> "\" Then
strPT = App.Path & "\LTY-PicTmp.WOK"
End If
If objFso.FileExists(strPT) = True Then
SetAttr strPT, vbArchive
End If
With cdlCLASS
.FileName = ""
.CancelError = False
.Filter = "All Picture (*.bmp;*.ico;*.wmf;*.jpg;*.gif) |*.bmp;*.ico;*.wmf;*.jpg;*.gif|" & _
"Bitmap (*.bmp)|*.bmp|" & _
"ICON (*.ico)|*.ico|" & _
"WMF (*.wmf)|*.wmf|" & _
"JPEG (*.jpg)|*.jpg|" & _
"GIF (*.gif)|*.gif|"
.Flags = cdlOFNFileMustExist Or _
cdlOFNHideReadOnly Or _
cdlOFNLongNames Or _
cdlOFNPathMustExist
.InitDir = App.Path
.ShowOpen
End With
If Len(cdlCLASS.FileName) <= 0 Then
Exit Sub
End If
If objFso.GetFile(cdlCLASS.FileName).Size >= 512000 Then
MsgBox "Sorry," & Chr$(13) & _
"The file is over 500 KB ," & Chr$(13) & _
"Please choose less than 500KB.", _
vbOKOnly, _
"Notice"
Exit Sub
ElseIf objFso.GetFile(cdlCLASS.FileName).Size < 512000 Then
If objFso.FileExists(strLTYD_FN) = True Then
objFso.CopyFile cdlCLASS.FileName, strPT, True
SetAttr strPT, vbArchive
objRst_LTYD_Card.Filter = "[ID] LIKE '001'"
If objRst_LTYD_Card.EOF = True Then
objRst_LTYD_Card.AddNew
objRst_LTYD_Card!ID = "001"
objRst_LTYD_Card!IDName = "IDCardNumber"
objRst_LTYD_Card.Update
End If
objRst_LTYD_Card.Requery
If objRst_LTYD_Card.EOF = False Then
With objStm
.Type = adTypeBinary
.Open
.LoadFromFile strPT
objRst_LTYD_Card!Foreground = .Read
objRst_LTYD_Card.Update
.Close
End With
imgCLASS_Card_F.Picture = LoadPicture(cdlCLASS.FileName)
ElseIf objRst_LTYD_Card.EOF = True Then
MsgBox "Sorry," & Chr$(13) & _
"It has a problem that cannot load the picture." & Chr$ (13) & _
"It is not found out this picture.", _
vbOKOnly, _
"Notice"
End If
objFso.DeleteFile strPT, True
End If
End If
Exit Sub
cmdCLASS_Card_F_Click_ER:
If Err.Number = cdlCancel Then
Exit Sub
Else
intERR_Count = intERR_Count + 1
Select Case intERR_Count
Case 0 To 19
Call frmPPE_Delay(1)
Resume
Case 20 To 30
Select Case MsgBox("Sorry, The program is busy now" & Chr$(13) & _
"It is may take a couple of minutes," & Chr$(13) & _
"Would you want to try again?" & Chr$(13) & Chr$(13) & _
"Yes: I want to waiting 3 second and then to execute it." _
& Chr$(13) & _
"No: I want to end.", _
vbYesNo + vbCritical, "Notice")
Case vbYes
Call frmPPE_Delay(3)
Resume Next
Case vbNo
Call frmPPE_Delay(1)
Exit Sub
End Select
Case Else
On Error GoTo 0
Exit Sub
End Select
End If
End Sub
- To preview these identification cards (ID Card):
Private Sub Command2_Click()
On Error GoTo ere
Dim a, b As Integer
For a = 0 To File1.ListCount
b = (((a + 1) - 1) Mod 5) + 1
If Len(File1.List(a)) > 0 Then
Set drt_Member_Card.Sections("Section1").Controls_
("drt_Member_Card_Fg" & Trim(Str(b))).Picture = imgCLASS_Card_F.Picture
Set drt_Member_Card.Sections("Section1").Controls_
("drt_Member_Card_Bg" & Trim(Str(b))).Picture = imgCLASS_Card_B.Picture
Set drt_Member_Card.Sections("Section1").Controls_
("drt_Member_Card_Photo" & Trim(Str(b))).Picture = _
LoadPicture(File1.Path & "\" & File1.List(a))
drt_Member_Card.Sections("Section1").Controls_
("drt_Member_Card_Name" & Trim(Str(b))).Caption = Mid$(File1.List(a), _
(Slider5.Value + 1), (Len(File1.List(a)) - 4) - (Slider5.Value))
If Slider5.Value > 0 Then
drt_Member_Card.Sections("Section1").Controls_
("drt_Member_Card_Num" & Trim(Str(b))).Caption = _
Left$(File1.List(a), Slider5.Value)
End If
End If
If (b Mod 5) = 0 Then
Set drt_Member_Card.DataSource = objRst_LTYD_Card.DataSource
drt_Member_Card.Show 1
ElseIf (b < 5) And (a = File1.ListCount) Then
Set drt_Member_Card.DataSource = objRst_LTYD_Card.DataSource
drt_Member_Card.Show 1
End If
Next a
Exit Sub
ere:
End Sub
Exception
- We use the instructions to catch errors and process it, the instructions are ‘
ON ERROR GOTO ...
’ and a label. - We need to VB6 runtime program to help execute this program. I suggest you can go to here (http://sourceforge.net/projects/vb6extendedruntime/) and download a package of the runtime program.
- Microsoft has provided VB6 runtime SP6 in there (http://support2.microsoft.com/vbruntime).
- How to install Visual Studio 6.0 in Windows Vista, 7 or later?
File Name: sp598ent.stf
13 Group 28 36 38 29 30 32 26 27 14 25 16 17 20 18 19 15 39 21 22 24 23 43
ß Problem in here.
14 CustomAction """sp598ent.dll"", ""GetPathFromReg"", _
""HKEY_LOCAL_MACHINE,Software\Microsoft\VisualStudio\6.0\Setup,VSCommonDir"" " _
%d\Common
(… More)
35 CustomAction "sp598ent.dll,ExitInFinalize,34"
36 Depend "27 ? : 37" ß Problem in here.
37 IsWin95 CustomAction "sp598ent.dll,CheckForMDAC" ß Problem in here.
Please change 36 to 38 and then delete 36 and 37 of string lines.
File Name: sp598ent.stf
13 Group 28 38 29 30 32 26 27 14 25 16 17 20 18 19 15 39 21 22 24 23 43
ß Change it.
14 CustomAction """sp598ent.dll"", ""GetPathFromReg"",
""HKEY_LOCAL_MACHINE,Software\Microsoft\VisualStudio\6.0\Setup,VSCommonDir"" "
%d\Common
(… More)
36 Depend "27 ? : 37" ß Delete it.
37 IsWin95 CustomAction "sp598ent.dll,CheckForMDAC" ß Delete it.
Save it. Now, you can keep installing Service Pack 5 and then you could find out it is working correctly.
- Introduction
We always need to refer to old code. Therefore, sometimes, we need to catch an idea from old code. For example, Visual Studio 6.0 has a lot of good code. But it is not installed Windows Vista, 7 or later. There is one way that helps you to install it in Windows Vista, 7 or later.
- Equipment
- Operation System: Windows Vista and Windows 7
- Development Tool: Microsoft Visual Studio 6.0
- Usage
If you were to install Visual Studio 6.0 on Windows when it told you that it is not supported. Please, force it to keep installing it. When it has been installed, finish and then you have to install Visual Studio 6.0 Service Pack 5 that you can use it in Windows Vista, 7 or later. However, there is a problem that it is not to install Service Pack 5. We have to fix it to help it for installation progress. To open the file ‘sp598ent.stf’ and then edit it. It is important that is find out ’13 Group 28 36’. The problem is in there. We need change its flow of installation. Please follow as below:
- Exception 1. If you find out the install program no responsibility when it searched to install component. Don’t worry. It is correct. Because your hard disk size is bigger than before and then it needs more time to find out that had been installed component. You just wait for it to search finish.
Acknowledgement
Thank you (Microsoft Visual Basic 6.0) very much for this great development utility.
Dr. Lai Tai-Yu received the Ph.D. from National Taipei University of Technology in 2016. He is the co-author of 2 journal, 25 conference papers, 6 books, 9 articles in the codeproject.com, and 2 patents inventions. His research interests lie in the areas of digital image processing and AI. He is a lecturer.
Dr Taiyu Lai. Stopień doktora, uzyskał w 2016 roku i objął stanowisko adiunkta na Wydziale. Ponadto jest autorem i współautorem: 2 publikacji artykułu w czasopiśmie naukowym, 25 artykułów opublikowanych w materiałach konferencyjnych, 6 książek, 9 eseje w monografiach codeproject.com, i posiada dwa patenty. Zainteresowania naukowe: przetwarzania obrazów i AI. Jest wykładowcą.
赖岱佑在2016年取得台北科技大学资讯工程博士学位,有2篇期刊、25篇会议论文、6本书籍、9篇文章在 codeproject.com 、2项专利。研究方向:数字图像处理和AI。现职是一位讲师。
賴岱佑在2016年取得台北科技大學資訊工程博士學位,有2篇期刊、25篇會議論文、6本書籍、9篇文章在 codeproject.com 、2項專利。研究方向:數位影像處理和AI。現職是一位講師。