borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Using VB to send sms text messages)Next Topic (Shell ) New Topic New Poll Post Reply
AndreaVB Forum : VB General : vb6 HELP! Barcode scanner then msaccess
Poster Message
mike
Level: Trainee

Registered: 20-03-2006

icon vb6 HELP! Barcode scanner then msaccess  Archived to Disk

Hi, i need to interface a barcode in a server computer, where the user will present their i.d and the program must verify whether the student is enrolled or not (i have a scanner which is a plug and play, the scanner can read the code and put it anywhere in the application where the cursor is into). The program must verify the i.d number and check it in the database. if he is erolled, then the next form which already contains his i.d number and his name, his password also would be ask to verify if he is really the one who owns the i.d

Pls help!! This is a part of my thesis' objective. i can't find any documentation about this, but i know this is already existing.

Thnx in advance

23-05-2002 at 03:30 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

Just trying to clarify, you just need to know how to compare a student ID to a list of valid IDs, then verify a password?

If so, then the easiest way is to open the table with a "SELECT * FROM [Students] WHERE SID='" & txtStudentID.Text & "'"

if data exists (valid id), then you'd have a record, if not valid, no records.

23-05-2002 at 06:40 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

Hi! thnx, but how will i put into code the checking of the i.d by the scanner without making any form, then if his i.d no. is in the database, a form will be shown that contains his name, i.d no. and a textbox asking his password. then the program checks the database to see if he his really the owner of the i.d because he knows the password

thnx jl

24-05-2002 at 02:41 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

Without a form at startup, you can put it in a module. Of course, I dont' know how the scanner passes the info to programs, probably a dll or something, but you'd have to retrieve it, and put in in the specified place.

It'd be something like:

Private sub Main()
     Dim adc as new ADODB.Connection
     Dim ars as new ADODB.Recordset

     Set adc = new ADODB.Connection
     Set ars = new ADODB.Recordset

     adc.Open '"Connection string, add a ADO control, create the connection string for it, then paste it here, delete the control"
     ars.Open "SELECT * FROM [Students] WHERE SID='" & HoweverGetIDFromScanner & "'"
     If not ars.BOF and not ars.EOF then
          frmVerify.Show
     End if

     If ars.State = adStateOpen then ars.Close
     If adc.State = adStateOpen then adc.Close
     Set ars = Nothing
     Set adc = Nothing
End Sub

24-05-2002 at 03:40 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

Hi! where will i put the source code? in the form? i or module? the barcode is plug and play type. when you scan a barcode, the decoded number will be placed where the cursor is. I think i can put an invisible text box and place the decoded number there. but the problem is how will i verify it in my database eventhough the user doesn't press the keyborad or doesn't click the mouse?

26-05-2002 at 01:48 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

I believe the textbox will have to be visible to put stuff in it, but I'd do the following with it:

Text1.Enabled=True
Text1.Visible=True
Text1.Locked=True
Text1.BackColor=vbButtonFace 'Make it look disabled
Text1.TabStop=False
Text1.SetFocus (at the form's startup, that way the cursor will always be there when loading, make sure form is visible first, otherwise an error will occur)

Then, have the following

Private Sub Text1_Change()
' Put the code here for verifying the barcode
' However, you may need to check the length first...
'IE:
     If len(Text1.Text)>=10 then
     ' Code to verify
     End If
End Sub

26-05-2002 at 09:19 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

Hi JL can you help me in making a source code that would verify the decoded code by the barcode scanner without pressing anything (e.g mouse or keypress). the program must check at once if the user presents his i.d at the barode, the program must know if he is enrolled or not by verifying the database(just by checking his i.d no.) the barcode is a plug and play type, no more programming is required. the number decoded will be placed where the cursor is. but i can't do it. If ever pls make it step by step because i'm not that good in programming Pls help or if possible pls give also references that will be needed in doing this program!

thnx a lot

27-05-2002 at 01:11 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

It's somewhat long, and would require testing on your side (that can't be done without the scanner!) and of course, the database name, connection string would have to be modified; as would the field names, but the following is "complete":

' ---- START Module ----
Private adc As New ADODB.Connection
Private ars As New ADODB.Recordset

Option Explicit

Private Sub Main()
    Init
    frmMain.Show
End Sub

Private Sub Init()
    Set adc = New ADODB.Connection
    Set ars = New ADODB.Recordset

'Connections, although locations, names change based on your format
'SQL
'    adc.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=StudentsID;Data Source=(local)"
'Access
    adc.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=StudentID;Persist Security Info=False"
End Sub

Private Sub DeInit()
    If ars.State = adStateOpen Then ars.Close
    If adc.State = adStateOpen Then adc.Close
    
    Set ars = Nothing
    Set adc = Nothing
End Sub

Public Sub Verify(ByVal BarCode As String)
    If ars.State = adStateOpen Then ars.Close
    ars.Open "SELECT * FROM [Students] WHERE SID='" & BarCode & "'", adc, adOpenStatic, adLockReadOnly
    If Not ars.BOF And Not ars.EOF Then
    'Verify Student Password
        With frmPWD
            .Show
            .lblSID = BarCode
            .lblStudentName = ars.Fields("StudentName")
        End With
    End If
End Sub

Public Function VerifyPassword(ByVal SID As String, ByVal PWD As String) As Boolean
    If ars.State = adStateOpen Then ars.Close
    
    ars.Open "SELECT * FROM [Students] WHERE SID='" & SID & "' AND PWD='" & PWD & "'"
    If Not ars.BOF And Not ars.EOF Then
        VerifyPassword = True
    Else
        VerifyPassword = False
    End If
End Function
'---- END Module ----



'---- START frmMain ----
'References:
'  Microsoft ActiveX Data Objects 2.x (x is any number, higher->newer)
' 1-Textbox txtBarCode
'Startp: Sub Main

Option Explicit

Private Sub Form_Load()
    Me.Visible = True
    DoEvents
    With txtBarCode
        .Enabled = True
        .Visible = True
        .Locked = True
        .BackColor = vbButtonFace 'Make look disabled
        .TabIndex = 0
        .TabStop = True
        .SetFocus
    End With
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    DeInit
End Sub

Private Sub txtBarCode_Change()
'If a student ID is a min of a certain length, put it here
'IE (for SSN, no dashes):
     If Len(Trim(txtBarCode.Text)) >= 9 Then
        Verify Trim(txtBarCode.Text)
     End If
End Sub
'---- END frmMain ----



'---- START frmPWD ----
' Set Borderstyle to 4-Fixed ToolWindow
' Two labels, 1 for Name, 1 for ID
' One command button
' one textbox (password char *, although not needed see code)
Private strPassword As String
Option Explicit

Private Sub cmdOK_Click()
    If VerifyPassword(lblSID.Caption, txtPWD.Text) Then
        MsgBox "Valid"
    Else
        MsgBox "Invalid"
    End If
' Didn't specify what to do from here
    Unload Me
End Sub

Private Sub Form_Load()

End Sub

Private Sub txtPWD_KeyPress(KeyAscii As Integer)
' Since there's programs to see the hidden passwords... store the info into a variable, put *'s in the text box
' this way all the programs can "steal" are the *'s
    If KeyAscii <> 8 And KeyAscii <> 13 Then
        strPassword = strPassword & Chr(KeyAscii)
    ElseIf KeyAscii = 8 Then
        strPassword = Left(strPassword, Len(strPassword) - 1)
    End If
    KeyAscii = Asc("*")
End Sub
'---- END frmPWD ----

27-05-2002 at 05:54 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

Thnx JL, i'll test the program as soon as possible. thnx again

28-05-2002 at 02:02 PM
View Profile Send Email to User Show All Posts | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

hi jL, there is an error in the program, maybe the i missed place some of them.
if i scan an i.d the program doesn't check the database and load the next form.


this is the error when i end the program
sub or function not defined
then
private sub_queryunload(....) is highlighted

Q?
1. what is the name of the database in your program? so i can change it, the name of my database is db1, the table containing the id number, name, and password is called tableEL.

2. if i double click a component, ex. textbox, form, command. where will i put the code under

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
sub or function not defined.


private sub_queryunload(....) is highlighted


thnx!!

28-05-2002 at 04:19 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

In sub Init:
    DB Name is: StudentID

In Verify Routines:
    Table name is: [Students]

so just change those to what you need (IE: [tableEL] instead of [Students])

change: Private Sub DeInit() to Public Sub DeInit()

since I didn't have anything to "start" the program with, I never got the error, I always bypassed it.

28-05-2002 at 05:08 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

hi jL, i made all the necessary changes but the program still doesn't work. the program doesn't have any errors but it's not working well. the program is not(i think) checking the database and if it does, it does not show the second form that contain the name id number and textbox for password. PLS HElP.


29-05-2002 at 01:05 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

Set a break point in the:

Private Sub txtBarCode_Change()

to see if it's run. If it's not, check to make sure that the number is displayed in the text field when you scan, and that the text box is named txtBarCode. The cursor should be blinking in the form when it's run. When I inserted a numbers into the textbox, it ran.

Also, if the barcode will only be validated if the code is >=9, if the code is less than that, you'll need to change the following line for your case [in the txtBarCode_Change routine]
     If Len(Trim(txtBarCode.Text)) >= 9 Then

Of course, it also assumes that the code you entered exists in the table, otherwise it won't load the second form. Set a breakpoint in the Verify routine.

Did you remember to change the SID= in the Verify routine to match the "Student ID number" field name? I'd believe so, since that would cause an error, but make sure.

----frmPWD Changes----
Also, in the frmPWD, in the cmdOK_Click change

VerifyPassword(lblSID.Caption, txtPWD.Text)
TO:
VerifyPassword(lblSID.Caption, strPassword)

AND add (just in case)

Private Sub Form_Load()
     strPassword=""
End Sub

----End frmPWD Changes----

[Edited by JLRodgers on 29-05-2002 at 11:12 AM GMT]

29-05-2002 at 05:01 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

hi jL, i'll test the program if it will work smoothly when i get home. thnx

30-05-2002 at 06:26 AM
View Profile Send Email to User Show All Posts | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

hi jL, i made a break point and i can't type any number in the textbox, maybe my placed some codes in the wrong form, can you send me again the codes with a step by step procedure. I can't make the program work. the database name is db1 and tabel name is tableEL.

thnx

01-06-2002 at 08:08 AM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

The text box is locked from user entering info, to allow users to enter info manually.

Change the following:

'---- START frmMain Modification----
Private Sub Form_Load()
    Me.Visible = True
    DoEvents
    With txtBarCode
        .Enabled = True
        .Visible = True
        .Locked = False 'FALSE=UserUditing, TRUE=NoUserEditing
        .BackColor = vbButtonFace 'Make look disabled
        .TabIndex = 0
        .TabStop = True
        .SetFocus
    End With
End Sub
'----END frmMain Modification----

01-06-2002 at 05:04 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

hi jl, the program has error Private Sub

Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    DeInit
End Sub

pls help. can't make your program run smoothly.

03-06-2002 at 02:28 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

If you changed the following line (like I had in a prior post), then I'm really confused (it's a standard VB form function).

change:
Private Sub DeInit() to Public Sub DeInit()

03-06-2002 at 04:34 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: vb6 HELP! Barcode scanner then msaccess  Archived to Disk

Hi JL thanks a lot. Sorry if i replied quite late. about the program that you gave me, it's now working, i just got the help menu of my compiler last Saturday. It helps alot, just like you. thnx again!!!

10-06-2002 at 03:04 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : vb6 HELP! Barcode scanner then msaccess
Previous Topic (Using VB to send sms text messages)Next Topic (Shell ) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder