Reply to thread

I am having a trouble with my project

 I want to convert this vb6 codes to vb 2008...can you help me??

 heres the codes:

 

 Option Explicit

 Dim SData(8) As Byte

 Dim SReply(8) As Byte

 Dim Replied As Boolean

  

  

 Private Sub cmdClear_Click()

 Dim i As Integer

 Dim dummy As String

  

 SData(1) = 5

 SData(2) = 0

 SData(3) = 0

 SData(4) = 0

 Call Checksum

 Replied = False

 dummy = MSComm1.Input

 For i = 0 To 7

 MSComm1.Output = Chr(SData(i))

 Next i

 While Replied = False

     DoEvents

     Wend

 txtResults.Text = "All Users deleted!"

 End Sub

  

 Private Sub cmdRead_Click()

 Dim i As Integer

 Dim dummy As String

 txtResults.Text = "Lagay mo daliri mo (isa lang!).."

 SData(1) = &HC

 SData(2) = 0

 SData(3) = 0

 SData(4) = 0

 SData(5) = 0

 Call Checksum

  

 dummy = MSComm1.Input

 For i = 0 To 7

 MSComm1.Output = Chr(SData(i))

 Next i

 Replied = False

 While Replied = False

     DoEvents

     Wend

  

 Timer1.Enabled = True

 While Timer1.Enabled = True

     DoEvents

     Wend

  

 If SReply(4) = 5 Then

     txtResults.Text = "Di kita kilala! Tsupi!"

     Else

     txtResults.Text = "Hello No. " + Str(SReply(2) * 256 + SReply(3)) + "  Welcome!"

     End If

  

 End Sub

  

 Private Sub cmdReg_Click()

 Dim i As Integer

 Dim dummy As String

 Dim V1, V2 As Integer

 Dim Good As Boolean

  

 Good = True

  

 V1 = Int(Val(txtUserNo.Text) / 256)

 V2 = Val(txtUserNo.Text) - V1 * 256

  

  

 SData(1) = 1

 SData(2) = V1

 SData(3) = V2

 SData(4) = 1

 Call Checksum

 Replied = False

 dummy = MSComm1.Input

 For i = 0 To 7

 MSComm1.Output = Chr(SData(i))

 Next i

 txtResults.Text = "Press a finger to register. We will do this 3 times."

 While Replied = False

     DoEvents

     Wend

  

 If SReply(4) <> 0 Then Good = False

 Timer1.Enabled = True

 While Timer1.Enabled = True

     DoEvents

     Wend

  

 SData(1) = 2

 Call Checksum

 dummy = MSComm1.Input

 txtResults.Text = "Press the same finger the second time..."

 Replied = False

 For i = 0 To 7

 MSComm1.Output = Chr(SData(i))

 Next i

  

 While Replied = False

     DoEvents

     Wend

  

 If SReply(4) <> 0 Then Good = False

 Timer1.Enabled = True

 While Timer1.Enabled = True

     DoEvents

     Wend

  

 SData(1) = 3

 Call Checksum

 dummy = MSComm1.Input

 txtResults.Text = "Press the same finger the last time..."

 Replied = False

 For i = 0 To 7

 MSComm1.Output = Chr(SData(i))

 Next i

 While Replied = False

     DoEvents

     Wend

  

 If SReply(4) <> 0 Then Good = False

 Timer1.Enabled = True

 While Timer1.Enabled = True

     DoEvents

     Wend

  

 If SReply(4) = 0 Then

     txtResults.Text = "Ok"

     Else

     txtResults.Text = "Error encountered! Repeat registration"

     End If

  

 End Sub

  

 Private Sub cmdRemove_Click()

 Dim i As Integer

 Dim dummy As String

 Dim V1, V2 As Integer

 V1 = Int(Val(txtUserNo.Text) / 256)

 V2 = Val(txtUserNo.Text) - V1 * 256

 SData(1) = 4

 SData(2) = V1

 SData(3) = V2

 SData(4) = 1

 Call Checksum

 Replied = False

 dummy = MSComm1.Input

 For i = 0 To 7

 MSComm1.Output = Chr(SData(i))

 Next i

 While Replied = False

     DoEvents

     Wend

 txtResults.Text = "User No. " + txtUserNo.Text + " Removed!"

 End Sub

  

  

  

  

 Private Sub Form_Load()

 MSComm1.PortOpen = True

 SData(0) = &HF5

 SData(7) = &HF5

 End Sub

  

 Public Sub Checksum()

 Dim i As Integer

 SData(6) = 0

 For i = 1 To 5

  

 SData(6) = SData(6) Xor SData(i)

 Next i

  

  

 End Sub

  

 Private Sub MSComm1_OnComm()

 Dim Rx As String

 Dim RxNumeric As String

 Dim i As Integer

  

 Rx = MSComm1.Input

 RxNumeric = ""

 For i = 1 To Len(Rx)

 SReply(i - 1) = Asc(Mid(Rx, i, 1))

 RxNumeric = RxNumeric + " " + Hex(SReply(i - 1))

 Next i

 txtWindow.Text = RxNumeric

 Replied = True

 End Sub

  

 Private Sub Timer1_Timer()

 Timer1.Enabled = False

 End Sub

 *NOTE it a source code from fingerprint scanner.

 


View the full article


Back
Top