VBMAN.QRcode - QR Code Generation Object
Overview
VBMAN.QRcode provides QR code generation functionality, using chain calling to set parameters and generate QR code images.
Core Features
- Chain Calling: Fluent API design
- Custom Content: Support any text content
- Custom Size: Configurable QR code size
- Custom Color: Configurable foreground color
- Clipboard Support: Can copy directly to clipboard
Methods
SetText
Set QR code content (chain calling)
vb
Public Function SetText(ByVal Content As Variant) As cQRcodeParameters:
Content- QR code content (text)
Example:
vb
VBMAN.QRcode.SetText("https://www.vb6.pro")SetSize
Set QR code size (chain calling)
vb
Public Function SetSize(ByVal Size As Long) As cQRcodeParameters:
Size- QR code size (pixels)
Example:
vb
VBMAN.QRcode.SetSize(200)SetForeColor
Set foreground color (chain calling)
vb
Public Function SetForeColor(ByVal ForeColor As OLE_COLOR) As cQRcodeParameters:
ForeColor- Foreground color (VB color constant or RGB value)
Example:
vb
VBMAN.QRcode.SetForeColor(vbBlue)
VBMAN.QRcode.SetForeColor(RGB(255, 0, 0))Generate
Generate QR code image
vb
Public Function Generate(Optional ByVal IsCopyToClipboard As Boolean) As StdPictureParameters:
IsCopyToClipboard- Whether to also copy to clipboard (default False)
Returns: StdPicture object
Example:
vb
' Generate QR code
Dim qrPic As StdPicture
Set qrPic = VBMAN.QRcode.Generate
' Display in picture box
Set Picture1.Picture = qrPic
' Generate and copy to clipboard
Set qrPic = VBMAN.QRcode.Generate(True)Comprehensive Examples
Example 1: Basic Usage
vb
Private Sub GenerateQR()
' Set content, size, color
With VBMAN.QRcode
.SetText("Hello VB6!")
.SetSize(150)
.SetForeColor(vbBlack)
' Generate and display
Set Picture1.Picture = .Generate
End With
End SubExample 2: URL QR Code
vb
Private Sub GenerateUrlQR()
Dim url As String
url = "https://github.com/vb6pro/vbman"
Set Picture1.Picture = VBMAN.QRcode _
.SetText(url) _
.SetSize(200) _
.SetForeColor(RGB(0, 102, 204)) _
.Generate(True) ' Also copy to clipboard
MsgBox "QR code generated and copied to clipboard!"
End SubExample 3: Save as Image File
vb
Private Sub SaveQRCode()
' Generate QR code
Dim qrPic As StdPicture
Set qrPic = VBMAN.QRcode _
.SetText(TextContent.Text) _
.SetSize(300) _
.Generate
' Display
Set Picture1.Picture = qrPic
' Save as image (requires GDI+ reference or use SavePicture)
SavePicture qrPic, App.Path & "\\qrcode.bmp"
MsgBox "Saved to: " & App.Path & "\\qrcode.bmp"
End SubDefault Values
- Default Content:
"hello vbman from www.vb6.pro" - Default Size:
50pixels - Default Color:
vbBlack(black)
Best Practices
- Size Selection: Choose appropriate size based on display needs and scanning distance
- Color Contrast: Ensure sufficient contrast between foreground and background colors
- Content Length: Too long content will make QR code dense, recommend shortening URL or using short links
- Error Handling: Returns Nothing when generation fails, needs to be checked