VB School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB Expert!

Join 300,459 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,630 people online right now. Registration is fast and FREE... Join Now!




VB6 for Drink Cans Recycling Machine

 

VB6 for Drink Cans Recycling Machine

nickycam

1 Jul, 2009 - 09:34 AM
Post #1

New D.I.C Head
*

Joined: 1 Jul, 2009
Posts: 1

Hi,

I'm in a bit of trouble here. A friend of mine built a machine running on VB6 that would crush drink cans for recycling purposes. However, the programmer he hired has left the country. Can anyone PLEASE help me out here? I need to complete the program for my friend. The sequences/processes of the can machine are:

1. Customer puts can into slot - door opens. Timer=5 sec.
2. Bar-code reader reads bar-code on can according to database. Timer=5 sec.
3. If no bar-code is detected, drink can, etc...is rejected & is removed by customer. Timer=10 sec.
4. If appropriate bar-code is detected, door of slot is closed & can is crushed. timer=5 sec.
5. Can is then disposed off into built-in container. Timer=3 sec.

Our problem is that the we cannot make the I/O card talk to the CPU. The I/O card input values are:

1. SW3 - Slot door opens (responsive to M3)
2. SW4 - Slot door closes (responsive to M4)
3. SW5 - Disposal door closes (responsive to M5)
4. SW6 - Disposal door opens (responsive to M6)
5. SW11 - Crusher forward switch (responsive to M11)
6. SW12 - Crusher home position (responsive to M12)

The I/O card output values are:

1. M3 - Slot door forward control valve
2. M4 - Slot door backward control valve
3. M5 - Disposal release door forward control valve
4. M6 - Disposal release door backward control valve
5. M11 - Crusher forward control valve
6. M12 - Crusher backward control valve

The VB script we have is:
CODE

Dim rs As New ADODB.Recordset
Dim connRMS As New ADODB.Connection
Private Sub barcodetxt_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then ' allow backspace
Exit Sub
End If
If Len(barcodetxt.Text) >= 13 Then
KeyAscii = vbEmpty
Exit Sub
End If

End Sub

Private Sub finishcmd_Click()
choices.Show
Unload Me
End Sub

Private Sub recyclecmd_Click()
'HERE THIS COMMAND USING FOR MANUAL RECYCLING
On Error Resume Next
connRMS.ConnectionString = "dsn=rms;uid=recycle;pwd=recycle123;"
connRMS.Open

rs.Open "select barcode,product_name,greenpoint,productpoint from member_barcode", connRMS, adOpenDynamic
While Not rs.EOF
If rs(0) = barcodetxt.Text Then
prolbl.Caption = rs(1)
gpointlbl.Caption = rs(2)
ppointlbl.Caption = rs(3)
recycleanslbl.Visible = True
recycleanslbl.Caption = " RECYCLE SUCCESSFULL!!!!!"
recycleanslbl.ForeColor = vbGreen
Timer1.Enabled = True
connRMS.Execute "update member_greenpoint set greenpoint=greenpoint + " & gpointlbl.Caption & " where mem_icpp_no= '" & icreslbl.Caption & "'"
connRMS.Execute "update copy_greenpoint set greenpoint=greenpoint + " & gpointlbl.Caption & " where mem_icpp_no= '" & icreslbl.Caption & "'"
rs.Close
rs.Open "select * from member_propoint", connRMS, adOpenDynamic
For i = 0 To rs.Fields.Count - 1
column_name = rs.Fields(i).Name
If prolbl.Caption = column_name Then
connRMS.Execute "update member_propoint set " & prolbl.Caption & " = " & prolbl.Caption & " + " & ppointlbl.Caption & " where mem_icpp_no = '" & icreslbl.Caption & "'"
connRMS.Execute "update copy_propoint set " & prolbl.Caption & " = " & prolbl.Caption & " + " & ppointlbl.Caption & " where mem_icpp_no = '" & icreslbl.Caption & "'"
End If
Next
rs.Close
If recyclecmd.Enabled = True Then
barcodetxt.Text = ""
rs.Open "select greenpoint from member_greenpoint where mem_icpp_no = '" & icreslbl.Caption & "'", connRMS, adOpenDynamic
gpreslbl.Caption = rs(0)
rs.Close
Else
choices.Show
barcodetxt.Text = ""
End If
connRMS.Close
Exit Sub
End If
rs.MoveNext
Wend
recycleanslbl.Visible = True
recycleanslbl.Caption = " SORRY NOT SUCCESSFULL, PLEASE REMOVE AND TRY AGAIN!!!"
recycleanslbl.ForeColor = vbRed
Timer1.Enabled = True
barcodetxt.Text = ""
barcodetxt.SetFocus
rs.Close
connRMS.Close
End Sub

Private Sub exitcmd_Click()
language.Show
Unload Me
End Sub

Private Sub Form_Load()
On Error Resume Next
connRMS.ConnectionString = "dsn=rms;uid=recycle;pwd=recycle123;"
connRMS.Open
rs.Open "select * from buffer ", connRMS, adOpenDynamic
icreslbl.Caption = rs(0)

rs.MoveNext
rs.Close
rs.Open "select * from member_greenpoint where mem_icpp_no='" & icreslbl.Caption & "'", connRMS, adOpenDynamic
gpreslbl.Caption = rs(1)
rs.Close
connRMS.Close
End Sub

Private Sub datacontrols()
icreslbl.Caption = rs!mem_ic_no & " "
gpreslbl.Caption = rs!green_points & ""
End Sub

Private Sub Timer1_Timer()
recycleanslbl.Visible = False
End Sub


Mod Edit: Please use code tags when posting your code. Code tags are used like so => code.gif

Thanks,
PsychoCoder smile.gif

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 02:13AM

Live VB Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month