Skip to content

Instantly share code, notes, and snippets.

@larsschenk
Last active December 31, 2019 15:13
Show Gist options
  • Save larsschenk/aebd8b77044f848fb1123ef6f68d490f to your computer and use it in GitHub Desktop.
Save larsschenk/aebd8b77044f848fb1123ef6f68d490f to your computer and use it in GitHub Desktop.
Visual Basic examples using the ActiveBarcode REST API
' On a form are an input field (Textbox1), a Picturebox (Picturebox1) and a button (Button1).
' If you click the button, a barcode with the text of the input field
' is called up via barcode API and drawn into the picturebox.
'
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim ReqUrl As String = "https://api.activebarcode.net/v1/png?access=YOUR-KEY-HERE&"
Dim ReqParam = "code =CODE128&width=" + CStr(PictureBox1.Width) _
+ "&height=" + CStr(PictureBox1.Height) _
+ "&text=" + TextBox1.Text
Dim req As System.Net.WebRequest = System.Net.WebRequest.Create(ReqUrl + ReqParam)
Using request As System.Net.WebResponse = req.GetResponse
Using stream As System.IO.Stream = request.GetResponseStream
PictureBox1.Image = New Bitmap(System.Drawing.Image.FromStream(stream))
End Using
End Using
End Sub
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment