Osprey
Osprey

Reputation: 1545

Integrating a QRCode library in VB.Net

I have been looking for a way to create QR Codes using VB.Net but I am going round in circles. I found some samples but they use C#. Also read about ZXing library but I have no idea about how to reference it (or what to reference). Can you suggest a tutorial (for complete beginners) as to how to go about finding an open source library and referencing it into a new VB.Net project?

So far the closest I got is this: http://www.codeproject.com/Articles/258779/Just-launched-new-open-source-project-QrCode-Net-a

and sample 3 seems to apply for me but I have no idea as to how to add that control to the toolbox. And the sample code is in C#.

Upvotes: 2

Views: 16671

Answers (3)

Thestas
Thestas

Reputation: 1

Not that I have any issue with the way you did it but this may be a little less code:

'fn: virtually unique file name based on date and time
Dim fn As String = "QR_" & String.Format("{0:MMddyyhhmmss}", DateTime.Now()) & ".png"
Dim txt As String = "Hello World"

Try
    Dim client As New System.Net.WebClient
    client.DownloadFile("http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=" & txt, Server.MapPath("~/TempFiles/" & fn))
    client = Nothing
Catch
End Try

'I have an <asp:label> on my form so I can quickly test if the file downloaded.
lblTest.Text = "<a href='~/TempFiles/" & fn & "' target='_blank'>Success?</a>"

Well, I wrote this for ASP.NET in VB. If anyone is trying to do this on a website, this can help.

Upvotes: 0

Steven Liekens
Steven Liekens

Reputation: 14088

You can use the C# library in your VB project by adding it to the solution as an existing project. Then right-click your VB project and select "Add reference". The QRCODE library should be listed on the "Projects" tab.

You can also skip adding the project to your solution and just add a reference to the DLL library if they provide it. But you won't be able to browse the C# code if you do that.

Upvotes: 1

Osprey
Osprey

Reputation: 1545

OK, so I kind of solved the problem. It is not ideal but it is simple and it works. What I did was using a combination of Google's online API QR Code service and URL image grabbing as described in this article:

http://forums.asp.net/t/631768.aspx/1

Using the function shown in the article above, I load this URL:

http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=Hello+World

Changing "Hello+World" with my string. I set the resulting image to a picture box and then I can do whatever I need with it.

The only downside is that the machine it is working on needs a permanent internet connection.

I am posting this answer just in case someone else has my own problem and for whom a permanent internet connection is not an issue.

I am still hoping someone can help me with an "off-line" version that can work on an isolated PC.

Upvotes: 0

Related Questions