printf for VB6


Author: Dave
Date: 09.21.13 - 2:01am



Here is a basic printf implementation for VB6.

If you use it in any serious code make sure to beef up the type checks and add error handling. It is a nicer way to build up complex strings without all those verbose and complicated ampersands, quotes and inline calls to hex(), ucase(), chr() etc.

Not shown below, but it also supports \t \r \n %%

Example:
    List1.AddItem printf("number 0x%x", 16)
    List1.AddItem printf("number %08x", &HCC)
    List1.AddItem printf("number %8X", &HCC)
    List1.AddItem printf("this is %s and can also be %S", "my string", "upper case")
    List1.AddItem printf("%s", "string with no prefix")
    List1.AddItem printf("0xCC in decimal = %d", &HCC)
    List1.AddItem printf("chr(&h41) = %c", &H41)
    List1.AddItem printf("chr(&h41) = %c it is my %s", &H41, "favorite letter")

Output:
    number 0x10
    number 000000CC
    number       CC
    this is my string and can also be UPPER CASE
    string with no prefix
    0xCC in decimal = 204
    chr(&h41) = A
    chr(&h41) = A it is my favorite letter






Comments: (0)

 
Leave Comment:
Name:
Email: (not shown)
Message: (Required)
Math Question: 36 + 70 = ? followed by the letter: L 



About Me
More Blogs
Main Site
Posts: (All)
2024 ( 1 )
2023 ( 9 )
2022 ( 4 )
2021 ( 2 )
2020 ( 4 )
2019 ( 5 )
2018 ( 6 )
2017 ( 6 )
2016 ( 22 )
2015 ( 15 )
2014 ( 25 )
2013 (4)
     MS GLEE Graphing
     printf for VB6
     C# App Config
     Tero DES C# Test
2012 (10)
     VC 2008 Bit Fields
     Speed trap
     C# Db Class Generator
     VB6 vrs .NET (again)
     FireFox Whois Extension
     git and vb6
     Code Additions
     Compiled date to string
     C# ListView Sorter
     VB6 Wish List
2011 ( 7 )
2010 ( 11 )
2009 ( 3 )