Page 1 of 2 12 LastLast
Results 1 to 40 of 70

Thread: [VB6/VBA] QR Code generator library

  1. #1

    Thread Starter
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    [VB6/VBA] QR Code generator library

    mdQRCodegen.bas is a single file no dependency pure VB6 implementation of a QR Code Generator based on https://www.nayuki.io/page/qr-code-generator-library



    Just add mdQRCodegen.bas to your project and call QRCodegenBarcode function to produce QR Code barcodes as vector based StdPicture objects.

    cheers,
    </wqw>

  2. #2
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,938

    Re: [VB6/VBA] QR Code generator library

    Very nice. I tried it with a few ASCII phrases, and my phone seemed to correctly translate them.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  3. #3
    Hyperactive Member
    Join Date
    Jun 2016
    Location
    EspaƱa
    Posts
    508

    Re: [VB6/VBA] QR Code generator library

    good job work perfect

  4. #4
    New Member
    Join Date
    Feb 2014
    Posts
    5

    Re: [VB6/VBA] QR Code generator library

    Thanks for sharing. Nice work!

  5. #5
    Lively Member saturnian's Avatar
    Join Date
    Dec 2017
    Location
    France
    Posts
    76

    Re: [VB6/VBA] QR Code generator library

    Very nice code !
    I made a small modification: I transformed the LNG_STEP constant into a variable to be able to modify the size of the QR code and copy it to the clipboard.
    This then makes it possible to insert it into a Word document, for example, or any other application...

    VbQRCodegen.zip

    Many thanks wqweto !

    FranƧois

  6. #6

    Thread Starter
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    Re: [VB6/VBA] QR Code generator library

    Quote Originally Posted by saturnian View Post
    Very nice code !
    I made a small modification: I transformed the LNG_STEP constant into a variable to be able to modify the size of the QR code and copy it to the clipboard.
    This then makes it possible to insert it into a Word document, for example, or any other application...

    VbQRCodegen.zip

    Many thanks wqweto !

    FranƧois
    Fixed in Allow using custom ModuleSize and reduce default to 10 (from 500) commit.

    Thanks!

    cheers,
    </wqw>

  7. #7
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: [VB6/VBA] QR Code generator library

    Thanks wqweto, for the code
    I used it for M2000 Interpreter
    https://georgekarras.blogspot.com/20...11-qrcode.html
    Attachment 185995

  8. #8
    New Member
    Join Date
    Jan 2017
    Posts
    3

    Re: [VB6/VBA] QR Code generator library

    thanks for sharing your projects. Great work

  9. #9
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: [VB6/VBA] QR Code generator library

    As the slang says here .... really crazy .... or great tool. WQWETO: How do I convert the image to text?

  10. #10
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: [VB6/VBA] QR Code generator library

    Use your phone scanner

  11. #11

    Thread Starter
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    Re: [VB6/VBA] QR Code generator library

    Quote Originally Posted by Episcopal View Post
    As the slang says here .... really crazy .... or great tool. WQWETO: How do I convert the image to text?
    Why would you want to do that?

    The idea of any barcode is to be read by a barcode scanner device. These are wands with laser beam used at cash registers and warehouses to scan barcodes on goods, packages, crates or whatever.

    Incidentally most modern smartphone's camera software allows the same to be used as a barcode scanner device too. This is how I tested the output of mdQRCodegen.bas -- by pointing my phone at the screen to test read the contents of it.

    cheers,
    </wqw>

  12. #12
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,938

    Re: [VB6/VBA] QR Code generator library

    Quote Originally Posted by Episcopal View Post
    As the slang says here .... really crazy .... or great tool. WQWETO: How do I convert the image to text?
    Maybe he wants the opposite of what you did, Wqweto. To take a scanned picture and convert it to text with VB6 code. That'd actually be quite the project. Find the orientation corners, rotate the picture to "square it up". Resize it to some standardized size. Then start going through the QR "pixels", seeing if they lean more toward white or black. And then do the reverse of what Wqweto's posted code does. Argh.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  13. #13
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,451

    Re: [VB6/VBA] QR Code generator library

    Here are a couple of projects by Olaf that can decode QR codes using RC6 (and libQuirc under the hood):

    https://www.vbforums.com/showthread....Code-Decoding)

    https://www.vbforums.com/showthread....ow-Positioning

  14. #14
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: [VB6/VBA] QR Code generator library

    Quote Originally Posted by Elroy View Post
    Maybe he wants the opposite of what you did, Wqweto. To take a scanned picture and convert it to text with VB6 code.
    Exactly.... Just like Wqweto did with pure code, I thought the opposite too. On the PSC (+-2015) before going offline there was an example of this in VB6... but in the GitHub repository it didn't reach it.

    I must have a backup, because I formatted the pc from that time to now .... if I find it, I'll come back here .....

    I have a source in C++..... by Phil Karn

  15. #15

    Thread Starter
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    Re: [VB6/VBA] QR Code generator library

    Just curious where do you plan on using such QR Code recognition? I cannot find a use-case for any practical purposes.

    Where do you have to process pictures with QR Codes, recognize there are QR Codes in view, extract the QR Codes and act on what is encoded?

    You must be involved in some really interesting projects that are beyond my imagination :-))

    cheers,
    </wqw>

  16. #16
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: [VB6/VBA] QR Code generator library

    I'm not involved in projects, as you mentioned. As you were curious, I was also curious to know and your module did the reverse .... then I came back here and asked ...

    I downloaded a qrcode reader and saw that its module works perfectly......

  17. #17

    Thread Starter
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    Re: [VB6/VBA] QR Code generator library

    I've never worked on or even seen a LOB application which needs OCR (Optical Character Recognition) of some kind for instance but probably QR Code recognition of scanned documents is more common though I highly doubt it.

    Another option is for the app to somehow handle video input from cameras but this would be rarely the case for a LOB application to fiddle with my laptop camera. I would be pretty scared if it did frankly.

    In any case why is QR Code recognition a thing outside specialized camera or scanner software is beyond me but yes, there are some libraries which generate QR Codes *and* can recognize QR Codes from images (which a completely different algorithm) however surprising such a feature might be.

    Alas QR Code recognition is never going to be supported by this QR Code generator library in a single .bas module as posted in the current thread.

    cheers,
    </wqw>

  18. #18
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,253

    Re: [VB6/VBA] QR Code generator library

    Quote Originally Posted by wqweto View Post
    ...probably QR Code recognition of scanned documents is more common...
    Yep, we use the RC5/RC6 QRDecode-stuff in a LOB-App like that.

    The scenario is: "personalized questionary-printouts" ...
    (for in-house participants at Seminars, who all receive "a Page" with a QR-encoded "participant-ID" in the TopLeft-corner):
    - which are later on (after the seminar was finished) fed "unordered" into a document-scanner
    - where the bunch of pages are scanned and converted to Tiffs directly, and placed on a Network-Share
    - from there we then read-out the TopLeft-Corner-Bitmap-part, QR-decode it ...
    - to be able to associate the "right file with the right participant" via a DB-Insert finally

    Olaf

  19. #19

    Thread Starter
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    Re: [VB6/VBA] QR Code generator library

    Yes, seems a possible use-case.



    Nowadays I bet you'd want the whole questionnaire to be online in first place.

    Edit: Btw, is RC5/RC6 QR Code gen/decode stuff a VB6 implementation?

    cheers,
    </wqw>

  20. #20
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,451

    Re: [VB6/VBA] QR Code generator library

    Another use would be at a construction site - you generate and post a unique QR code at each room/floor/whatever unit you like, and when it's time to do a site/progress review the reviewer can walk around with their Surface and snap QR codes as they go. As they type their report and take pictures of any deficiencies, everything will automatically be linked to specific locations, with no chance to type/pick the wrong room #.

  21. #21
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,253

    Re: [VB6/VBA] QR Code generator library

    Quote Originally Posted by wqweto View Post
    Yes, seems a possible use-case.
    Nowadays I bet you'd want the whole questionnaire to be online in first place.
    We suggested this at the time, using a "BYOD-scheme" (where Users fill out the form on their own SmartPhones),
    but our customer said "No" (because they have always a percentage of "older participants", which might not be able to configure their Phones for that - or didn't even own one).

    Then we suggested to "just buy 30 cheap ARM-Tablets, which ca be pre-configured" -
    but this was denied as well ("too expensive").

    So, "Paper it was"...

    Quote Originally Posted by wqweto View Post
    Btw, is RC5/RC6 QR Code gen/decode stuff a VB6 implementation?
    Here's an excerpt from _Library-Licenses.txt (as included in the RC6-BaseDlls-package):
    Code:
       - libqrencode (the "quasi-standard" by Kentaro Fukuchi)
         http://fukuchi.org/works/qrencode/
         LGPL 2.1 license (https://www.gnu.org/licenses/lgpl-2.1.html)
         
       - quirc-library (small and efficient QR-Decoding by Daniel Beer)
         https://github.com/dlbeer/quirc
         It's a "personalized license" which comes below:
         Copyright (C) 2010-2012 Daniel Beer <dlbeer@gmail.com>
            Permission to use, copy, modify, and/or distribute this software for
            any purpose with or without fee is hereby granted, provided that the
            above copyright notice and this permission notice appear in all
            copies.
    
            THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
            WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
            WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
            AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
            DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
            PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
            TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
            PERFORMANCE OF THIS SOFTWARE.
    HTH

    Olaf

  22. #22
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,938

    Re: [VB6/VBA] QR Code generator library

    Personally, I think the work that Wqweto has provided herein is fantastic.

    And he further stated...

    Alas QR Code recognition is never going to be supported by this QR Code generator library in a single .bas module as posted in the current thread.
    So Episcopal, we'll be watching for your CodeBank entry to interpret scanned QR codes.

    And, truth be told, this all sounds like it should be a separate thread in the regular VB6 Q&A section.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  23. #23

    Thread Starter
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    Re: [VB6/VBA] QR Code generator library

    In latest update QR codes generated are with fancy rounded modules by default (inspired by Telegram activation codes)



    Surprisingly such eye-candy does not render barcodes unreadable :-))

    MS Access users might want to use new QRCodegenConvertToData function with the native Image control like this

    Code:
    Image0.PictureData = QRCodegenConvertToData(QRCodegenBarcode("https://www.vbforums.com"), 500, 500)
    . . . to feed PictureData property with a raw byte-array of BMP rescaled with anti-aliasing to 500x500 pixels.

    cheers,
    </wqw>

  24. #24
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    603

    Re: [VB6/VBA] QR Code generator library

    so advance code, please educate me how it works? I couldn't find any dll file of the nayuki.io reference but it works like magic.

  25. #25
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: [VB6/VBA] QR Code generator library

    How we get the picture from byte array later?

  26. #26

    Thread Starter
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    Re: [VB6/VBA] QR Code generator library

    Quote Originally Posted by georgekar View Post
    How we get the picture from byte array later?
    Take a look at Form1.frm source code, there is no need to use byte-arrays in VB6 because you can just use Set Image1.Picture = QRCodegenBarcode("Sample Text") to directly display the vector image.

    In MS Access it's not possible to use StdPicture like this so they have to use Image0.PictureData = QRCodegenConvertToData(QRCodegenBarcode("Sample Text")) instead.

    If you want to rasterize the vector image returned from QRCodegenBarcode for one reason or another you can use QRCodegenResizePicture on the returned StdPicture.

    If you want to rasterize the vector and anti-alias the result (by super sampling w/ StretchBlt in HALFTONE mode) then you have to use QRCodegenResizePicture twice like this:

    Code:
        '--- from QRCodegenConvertToData source code 
    
        If NewWidth > 0 And NewHeight > 0 Then
            '--- super sample to 4x4 for cheap anti-aliasing
            Set pPicture = QRCodegenResizePicture(pPicture, NewWidth * 4, NewHeight * 4)
            Set pPicture = QRCodegenResizePicture(pPicture, NewWidth, NewHeight)
        End If
    cheers,
    </wqw>

  27. #27
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    603

    Re: [VB6/VBA] QR Code generator library

    Quote Originally Posted by DaveDavis View Post
    so advance code, please educate me how it works? I couldn't find any dll file of the nayuki.io reference but it works like magic.
    so curious how it works, I can't figure out where is the library.

  28. #28

    Thread Starter
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    Re: [VB6/VBA] QR Code generator library

    Quote Originally Posted by DaveDavis View Post
    so curious how it works, I can't figure out where is the library.
    It's a single standard module library. There is no external dependency as the original C code is completely translated to VB6.

    With standard BAS modules you can only use whichever procedures you need and the ones you don't call will be removed by the linker from the final binary (which is not the case with class modules, forms and user-controls).

    cheers,
    </wqw>

  29. #29
    New Member
    Join Date
    Nov 2022
    Posts
    2

    Re: [VB6/VBA] QR Code generator library

    I've been exploring the new QRCodegenConvertToData (wow - and thank you) to push the data into the native Access image control

    Code:
    Image1.PictureData = QRCodegenConvertToData(mdQRCodegen.QRCodegenBarcode("https://www.vbforums.com"))
    The above code works as expected, I plan to experiment and see if I can get the native controls to also bind to a control source.

    Code:
    Image1.PictureData = QRCodegenConvertToData(mdQRCodegen.QRCodegenBarcode("https://www.vbforums.com", SquareModules:=True), 500, 500)
    The code above with square modules works (mostly)
    It (curiously) rotates the QR code, and, if width and height are omitted, itfails to draw the QR code

  30. #30
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: [VB6/VBA] QR Code generator library

    Something going wrong with the curved one. Just check the image (using clipboard to pass it), to Word 365, and check the print preview. Lines between small squares are not white (so we can see it). Only M2000 environment can render to bitmap, first by exporting to a memory buffer as emf file and then using GDI plus for rendering.

    Name:  qrcodeProblem.jpg
Views: 5981
Size:  63.2 KB

  31. #31

  32. #32

    Thread Starter
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    Re: [VB6/VBA] QR Code generator library

    Just fixed the obvious issues with WinWord and MS Paint in commit 640be96 but there is still some "halo" effect in office applications due to the anti-aliasing these perform with (probably) a custom EMF playback implementation.

    To remove this "halo" effect I'll have to come up with completely different renderer which solves for a minimum set of non-overlapping black polygons which when composited will produce the verbatim image of the QR code.

    cheers,
    </wqw>

  33. #33

    Thread Starter
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    Re: [VB6/VBA] QR Code generator library

    JFYI, the all new polygons based renderer in commit 138cea2 produces vector EMFs which are displayed very well both in WinWord and MS Paint (in both square and rounded modules modes).



    cheers,
    </wqw>

  34. #34
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: [VB6/VBA] QR Code generator library

    Bravo, its ok, with Word 365, Paint, Inkspace and always in M2000 Interpreter (which included)

  35. #35
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,477

    Re: [VB6/VBA] QR Code generator library

    Great work wqweto. Attached is a version modified to use as a Class module.

    J.A. Coutts
    Attached Files Attached Files

  36. #36

    Thread Starter
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    Re: [VB6/VBA] QR Code generator library

    Btw, there is one clear benefit to using standard modules for shared "libraries" -- the procedures which are not called from anywhere in the client project a .bas file is included into are not compiled in final executable due to a simple link-time optimization.

    With a class module you get *every* procedure compiled into final executable *always* because public (and private) methods are referenced from its VTable as emitted from the VB compiler -- bummer!

    cheers,
    </wqw>

  37. #37
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,938

    Re: [VB6/VBA] QR Code generator library

    Quote Originally Posted by wqweto View Post
    Btw, there is one clear benefit to using standard modules for shared "libraries" -- the procedures which are not called from anywhere in the client project a .bas file is included into are not compiled in final executable due to a simple link-time optimization.
    I did not know that, and it's good to know. And another advantage of a BAS over a one-time-CLS is that you don't have to jump through the hoops of adding the ObjPtr to the argument list and you don't have to deal with rearranging the HRESULT return and the actual return of functions.

    For one-time-CLS modules, the only advantage I see is that they have Initialize and Terminate events, which are admittedly handy.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  38. #38

    Thread Starter
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    Re: [VB6/VBA] QR Code generator library

    For "library" code i.e. code which will be reused in multiple projects an optimal strategy is to implement everything as a BAS file with a lot of public procedures which hopefully get trimmed (together with their dependent private procedures which are used only by any trimmed ones) if unused in a particular project.

    So instead of implementing Compress procedure with an EncryptStrength parameter and conditionally call pvEncrypt procedure do separate public Compress and Encrypt procedures so that encryption procedure (and all its dependant private ones) can be trimmed by the linker if compression is used without encryption i.e. the design of "library" code is important too.

    cheers,
    </wqw>

  39. #39
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: [VB6/VBA] QR Code generator library

    Quote Originally Posted by wqweto View Post
    Btw, there is one clear benefit to using standard modules for shared "libraries" -- the procedures which are not called from anywhere in the client project a .bas file is included into are not compiled in final executable due to a simple link-time optimization.
    Wqweto ... This includes all public methods?

    Edit: hummmmm ....... ok!
    Last edited by Episcopal; Jan 22nd, 2023 at 08:29 PM.

  40. #40
    New Member
    Join Date
    Apr 2023
    Posts
    1

    Re: [VB6/VBA] QR Code generator library

    Hi,

    I use MS Access 2000 and when I tried generate QR by using
    Code:
    Image0.PictureData = QRCodegenConvertToData(QRCodegenBarcode("https://www.vbforums.com"), 500, 500)
    I got error 2191 The bitmap you specified is not in a device-independent bitmap (.dib) format.

    Is some solution for that error?

    Kind regards

    Quote Originally Posted by wqweto View Post
    In latest update QR codes generated are with fancy rounded modules by default (inspired by Telegram activation codes)



    Surprisingly such eye-candy does not render barcodes unreadable :-))

    MS Access users might want to use new QRCodegenConvertToData function with the native Image control like this

    Code:
    Image0.PictureData = QRCodegenConvertToData(QRCodegenBarcode("https://www.vbforums.com"), 500, 500)
    . . . to feed PictureData property with a raw byte-array of BMP rescaled with anti-aliasing to 500x500 pixels.

    cheers,
    </wqw>

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width