Microsoft Knowledge Base Email Alertz

KBAlertz.com: Data files created with older Microsoft Basic products (Quick Basic, GW-Basic, and Basica (IBM and Compaq licensed Basic)) may not be readable by Visual Basic for Windows.

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
KBAlertz referrals get
** SIX MONTHS FREE **


Community Site



We Send hundreds of thousands of emails using ASP.NET Email


ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 140520 - Last Review: August 9, 2004 - Revision: 2.2

PRB: Converting MBF to IEEE in Visual Basic for Windows

This article was previously published under Q140520

On This Page

SYMPTOMS

Data files created with older Microsoft Basic products (Quick Basic, GW-Basic, and Basica (IBM and Compaq licensed Basic)) may not be readable by Visual Basic for Windows.

CAUSE

Prior to the IEEE floating point standard being widely accepted, Microsoft used an internal floating point format known as Microsoft Binary Format (MBF). The IEEE standard was introduced later and became the industry standard.

Early versions of Microsoft QuickBASIC and GW-Basic supported only MBF format. In Microsoft Basic Professional Development System (PDS) and Visual Basic for MS-DOS, functions are available to convert between MBF and IEEE formats. As Microsoft moved toward complete acceptance of the IEEE standard, however, support for the MBF format was removed.

Visual Basic for Windows uses the IEEE standard. The MBF format, however, is incompatible with the IEEE standard and data saved in this manner will not be readable.

RESOLUTION

The PDS and Visual Basic for MS-DOS products contained functions that convert between MBF format and IEEE format. These functions are not available in Visual Basic for Windows. Here are two possible workarounds to this dilemma:
  1. A program can be written in PDS or Visual Basic for MS-DOS that re-creates the file containing the MBF data. After reading the file information into PDS or Visual Basic for MS-DOS, you can use the MKxMBF$ functions (see the manuals for PDS or Visual Basic for MS-DOS or their Help menus) to convert the data to IEEE format. This method is preferred for two reasons:
    • It converts your data to IEEE so that other programs can access your files.
    • If you use method 2, your program will need an extra DLL that you must distribute with your application.
  2. Previously, there was no way to convert the data from Visual Basic for Windows. But now there is a DLL available to do this. This DLL (MBF2IEEE.DLL) contains functions that simulate the MKS, MKD, CVS, and CVD functions that were present in some of the MS-DOS-based Basic products. These functions (MKS, MKD, CVS, and CVD) do not exist in Visual Basic for Windows, thus the need for this DLL. The MORE INFORMATION section below gives details about the DLL and explains how to download it from the Microsoft Download Center.

STATUS

This behavior is by design.

MORE INFORMATION

Details About Method Two: Using Mbf2ieee.dll

NOTE: These functions all do conversions between Microsoft Binary Format (MBF) and IEEE floating point values. Some of the newer MS-DOS-based Basic products had versions of these functions that worked differently. For example, they let you look at an IEEE number as a string without converting it to MBF. The routines described here are only provided as a way of retrieving old MBF data.

These functions provide conversions between IEEE floating point values and Microsoft Binary Format (MBF) floating point values. Below is a set of declare statements which must be included in a Visual Basic program which calls these functions:
   Public Declare Function Cvs Lib "MBF2IEEE.DLL" (X As String) As Single
   Public Declare Function Cvd Lib "MBF2IEEE.DLL" (X As String) As Double
   Public Declare Function Mks Lib "MBF2IEEE.DLL" (X As Single) As String
   Public Declare Function Mkd Lib "MBF2IEEE.DLL" (X As Double) As String
				

Below is a description of each of these functions along with an example.

CVS and CVD Functions

These functions accept a 4-byte (CVS) or 8-byte (CVD) string as an argument. They expect the bit pattern of this string to represent a single or double precision MBF value, respectively. The function returns an IEEE result.
   Dim MBF As String, IEEE As Single
   ' load the string from a file, etc.
   IEEE = CVS(MBF)
				

MKS and MKD Functions

These functions accept an IEEE single (MKS), or double (MKD) precision value as an argument. It then converts this value into a 4-byte or 8-byte MBF value and returns it in a string.
   Dim MBF AS String, IEEE As Single
   MBF = MKS(IEEE)
   ' Now write the MBF value out to disk
				

Potential Problems

There are differences between the IEEE format and MBF. For this reason precision may be lost during the translations. It is also possible that a number cannot be converted between the two formats. If this is the case, a Visual Basic Overflow (Error #6) is generated. This is a trappable error, so handle the error accordingly.

How to Get Mbf2ieee.dll

The following file is available for download from the Microsoft Download Center:
Mbf2ieee.exe (http://download.microsoft.com/download/vb30/install/1/win98/en-us/mbf2ieee.exe)
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591  (http://kbalertz.com/Feedback.aspx?kbNumber=119591/EN-US/ ) How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file. After downloading Mbf2ieee.exe, run it to obtain Mbf2ieee.dll along with the source files and a Mbf2ieee.txt file, which is a readme that contains the text of this article.

Source Code Included in Mbf2ieee.exe

In addition to the .dll itself, the source code is also provided, so you can make modifications and recompile if you have Microsoft C. To recompile and build a new .DLL file, you must use Microsoft C because the routines are specific to Microsoft C and rely on the way Microsoft C returns floating point Values. This source code does not compile with Borland C.

To recompile with Microsoft C, use the following command line statements to build the DLL:
    cl -ALw -Ow -W2 -Zp -Tp mbf2ieee.c
    link /nod c:\vb\cdk\vbapi.lib mbf2ieee, mbf2ieee.dll, NUL, sdllcew
       oldnames libw, mbf2ieee
    rc -t mbf2ieee.dll
    implib mbf2ieee.lib mbf2ieee.def
				

APPLIES TO
  • Microsoft Visual Basic 4.0 Professional Edition
  • Microsoft Visual Basic 4.0 16-bit Enterprise Edition
Keywords: 
kbdownload kb16bitonly kbfile kbprb kbsample KB140520
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please