Sample Applications A-5
'************************************************************
'* txtUPC_KeyDown Event
'* Description:
'* Handle the KeyDown event to determine the
'* type of character entered into the control.
'* if Enter is Pressed, execute the btnEnter_Click Event
'************************************************************
Private Sub txtUPC_KeyDown(ByVal sender As Object, ByVal e
As System.Windows.Forms.KeyEventArgs) Handles txtUPC.KeyDown
If (e.KeyCode.ToString() = "Return") Then
btnEnter_Click(sender, e)
End If
End Sub
'************************************************************
'* btnEnter_Click Event
'* Description:
'* If length of data is 12 print label if not
'* display error message
'************************************************************
Private Sub btnEnter_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnEnter.Click
Dim fmtUPCA As String = "{F,1,A,R,E,200,200," & Chr(34)
& "UPCA" & Chr(34) & "|" _
& "C,150,49,0,50,8,8,A,L,0,0," & Chr(34) & "Demo
VB.NET" & Chr(34) & "|" _
& "B,1,12,F,25,28,1,4,100,7,L,0|}"
Dim rPrint As New Print
' Instantiate Print class
If (txtUPC.Text.Length <> 12) Then
' Make sure Length is 12
MsgBox("Invalid Length", MsgBoxStyle.OKOnly, "Entry
error")
txtUPC.Text = ""
' Reset content to nothing
txtUPC.Focus()
' Focus on the text box
Else
rPrint.ClearError()
' Clear any errors
If (Not rPrint.IsBatteryOKToPrint) Then