1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Private Declare Function AddFontResource Lib "gdi32" _
Alias "AddFontResourceA" (ByVal lpFileName As String) As Long
Private Sub txbCode_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txbCode.TextChanged
Dim codeBar, codeClair
If txbCode.Text <> "" Then
'MsgBox("Bonjour")
codeClair = txbCode.Text & New String("0", EANLen - Len(txbCode.Text))
codeBar = IIf(EANLen = 7, EAN8(codeClair), EAN13(codeClair))
lblCodeBar.Text = codeBar
If File.Exists("C:\Windows\Fonts\ean13.ttf") Then
MsgBox("police installée: OK !")
Else
MsgBox("police doit être installée")
Try
AddFontResource("C:\temp\ean13.ttf")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If
lblDessinCode.Font = New Font("Code EAN13", 48, FontStyle.Regular)
lblDessinCode.Text = codeBar
End If
End Sub |
Partager