Skip to content

cQRcode Methods Reference

🔗 Chainable Setting Methods

SetText

Sets QR code content.

vb
Public Function SetText(ByVal Content As Variant) As cQRcode

Parameters:

  • Content - QR code text content (String or Byte Array)

Returns: Returns self instance for chainable calls

Example:

vb
' Set text
QR.SetText("Hello World")

' Set URL
QR.SetText("https://www.vb6.pro")

' Set WiFi config
QR.SetText("WIFI:T:WPA;S:MyWiFi;P:password;;")

' Chainable call
QR.SetText("Content").SetSize(200).Generate

SetSize

Sets QR code image size (pixels).

vb
Public Function SetSize(ByVal Size As Long) As cQRcode

Parameters:

  • Size - Image size (pixels)

Default: 50

Example:

vb
' Set small size
QR.SetSize(100)

' Set large size (HD)
QR.SetSize(500)

' Adaptive to container
QR.SetSize(Picture1.Width)

SetForeColor

Sets QR code foreground color.

vb
Public Function SetForeColor(ByVal ForeColor As OLE_COLOR) As cQRcode

Parameters:

  • ForeColor - Color value (VB color constant or RGB value)

Default: vbBlack

Example:

vb
' Use VB constants
QR.SetForeColor(vbRed)
QR.SetForeColor(vbBlue)

' Use RGB
QR.SetForeColor(RGB(255, 0, 0))    ' Red
QR.SetForeColor(RGB(0, 128, 0))    ' Green
QR.SetForeColor(&HFF6600)           ' Orange

' Chainable call
QR.SetText("Color").SetForeColor(vbBlue).Generate

🎯 Generation Methods

Generate

Generates QR code image.

vb
Public Function Generate(Optional ByVal IsCopyToClipboard As Boolean) As StdPicture

Parameters:

  • IsCopyToClipboard - Whether to copy to clipboard at same time (default False)

Returns: StdPicture object

Example:

vb
Dim QR As New cQRcode

' Basic generation
Set Image1.Picture = QR.Generate()

' Generate and copy to clipboard
QR.Generate True

' Complete flow
Set Image1.Picture = QR _
    .SetText("https://vb6.pro") _
    .SetSize(300) _
    .SetForeColor(vbBlack) _
    .Generate()

📋 Common Use Scenarios

Generate URL QR Code

vb
Private Sub GenerateURLQR()
    Dim QR As New cQRcode
    
    Set Image1.Picture = QR _
        .SetText("https://www.microsoft.com") _
        .SetSize(200) _
        .Generate()
End Sub

Generate WiFi QR Code

vb
Private Sub GenerateWiFiQR()
    Dim QR As New cQRcode
    Dim wifiConfig As String
    
    ' WiFi config format
    wifiConfig = "WIFI:T:WPA;S:" & txtSSID.Text & ";P:" & txtPassword.Text & ";;"
    
    Set Image1.Picture = QR _
        .SetText(wifiConfig) _
        .SetSize(250) _
        .Generate()
End Sub

Generate Contact QR Code (vCard)

vb
Private Sub GenerateVCardQR()
    Dim QR As New cQRcode
    Dim vCard As String
    
    vCard = "BEGIN:VCARD" & vbCrLf & _
            "VERSION:3.0" & vbCrLf & _
            "N:John" & vbCrLf & _
            "TEL:13800138000" & vbCrLf & _
            "EMAIL:john@example.com" & vbCrLf & _
            "END:VCARD"
    
    Set Image1.Picture = QR _
        .SetText(vCard) _
        .SetSize(300) _
        .Generate()
End Sub

Batch Generate QR Codes

vb
Private Sub BatchGenerate()
    Dim QR As New cQRcode
    Dim items As Variant
    Dim i As Long
    
    items = Array("Item1", "Item2", "Item3", "Item4", "Item5")
    
    For i = LBound(items) To UBound(items)
        ' Generate QR code
        Set Image1.Picture = QR _
            .SetText(items(i)) _
            .SetSize(150) _
            .Generate()
        
        ' Save file
        SavePicture Image1.Picture, App.Path & "\QR_" & items(i) & ".bmp"
    Next i
End Sub
vb
Private Sub PrintQR()
    Dim QR As New cQRcode
    
    ' Generate high-quality QR code
    Set Image1.Picture = QR _
        .SetText("Print Test") _
        .SetSize(500) _
        .Generate()
    
    ' Print
    Printer.PaintPicture Image1.Picture, 500, 500
    Printer.EndDoc
End Sub

Last Updated: 2026-05-17

VB6 and LOGO copyright of Microsoft Corporation