Proof that anyone can do it RSS 2.0
 Friday, March 12, 2004

I am working on a project that requires importing a large amount of data from 'text data files' that were originally created with QuickBasic (in the 1980's).  One (not-so-quick) lesson I've just learned...that old text isn't written with ISO, UTF, or even ASCII encoding.  It's windows-1252. 

The problem showed up when trying to convert a two-bit string into an integer (the pointer to a related record) with the CVI() function.  Those funny little non-usual characters don't come through correctly with any other code page...

With a simple line:

Encoding encoding = Encoding.GetEncoding(1252);

Everything works. 

Friday, March 12, 2004 2:43:54 PM UTC  #    -
.NET | QuickBasic
 Friday, February 06, 2004

At my day job, I've been working to update an old quickbasic-centered data storage system to something a little more 21st century.  Along the way, of course, I've had to learn a great deal about QuickBasic and how it stores/retrieves values in text files. 

Our data solution uses fixed-length text records for storage.  One 'quirk' about that is that it also uses QuickBasic's CVI() and MKS() functions to store 16-bit Integers in a 2-character string (so any integer will still fit into our happy little fixed-length string). 

The problem is that Microsoft's .NET doesn't have any functions that resemble CVI(), MKS(), or a number of others that were found in QB (like MKD, CVD, MKI, MKL, CVL).  There are plenty of examples out there for VB6, but not .NET!

Anyway, I've searched pretty hard for a .NET version of CVI(), and finally found one that would work:

Here's the link to the original article, and I'll attach the code for download in case that article goes away some time in the future:

I hope this helps someone else with the same problem.

CV and MK Functions.txt (4.85 KB)
Friday, February 06, 2004 7:27:54 PM UTC  #    -
.NET | QuickBasic
Archive
<July 2008>
SunMonTueWedThuFriSat
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789
Quick Quips
    About the author/Disclaimer

    Disclaimer
    The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

    © Copyright 2008
    John Bowen
    Sign In
    Statistics
    Total Posts: 152
    This Year: 3
    This Month: 0
    This Week: 0
    Comments: 164
    Themes
    Pick a theme:
    All Content © 2008, John Bowen
    Theme modified from the 'Business' theme created by Christoph De Baene (delarou)