Click here to Skip to main content
15,888,053 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i need to generate a barcode without any library (if exist one commercial free),
i have this code but always said
Font is ReadOnly,
i found a lot of pages but any said how fix it
this is the code :

VB.NET
Imports System.Drawing
Imports System.Drawing.Text

Partial Class codigo_barras
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        Dim family As FontFamily
        Dim pfc As PrivateFontCollection
        pfc = New PrivateFontCollection()
        pfc.AddFontFile("C:\Fonts\EAN-13.TTF")
        family = pfc.Families(0)

        TextBox1.Enabled = False
        TextBox1.Font = Font(family, 40.0F)
        TextBox2.Text = String.Format("*{0}*", "123456")

    End Sub

End Class


What I have tried:

i tried to find how fix it but any page said something usefull, only if you use libraries or dll, works perfectly, but i need without any library, or not pay for commercial use
and i don't now how fix this error, if you do for windows aplication works, but i nee for asp.net in vb.
Posted
Updated 8-Mar-16 2:07am
Comments
CHill60 8-Mar-16 7:59am    
TextBox1.Font = Font(family, 40.0F) doesn't look right ... should that be TextBox1.Font = New Font(family.Name, 40.0F) ?

1 solution

Probably you need to change:
VB
TextBox1.Font = Font(family, 40.0F)
To:
VB
TextBox1.Font = New Font(family, 40.0F)
 
Share this answer
 
Comments
Member 12156089 8-Mar-16 14:21pm    
i use both

TextBox1.Font = Font(family, 40.0F)
TextBox1.Font = New Font(family, 40.0F)

still said read only i don't now what to do

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900