[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference abbott::visual_basic

Title:Microsoft Visual Basic
Moderator:TAMARA::DFEDOR::fedor
Created:Thu May 02 1991
Last Modified:Thu Jun 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2565
Total number of notes:10453

2480.0. "Recovering data stored using MKS$ ??" by MSOPW2::TREMELLING (Making tomorrow yesterday, today!) Thu Jan 23 1997 11:19

T.RTitleUserPersonal
Name
DateLines
2480.1MBF2IEEE.DLL is what you need (I think) RTOMS::CLARKENLike a Spider to a FlyFri Jan 24 1997 07:05216
G'day,

 I think the following article explains how to solve your problem

 Nic

PRB: VB 3: Converting MBF to IEEE in Visual Basic for Windows 
Article ID: Q113439
Revision Date: 03-JUN-1996
 
The information in this article applies to:

- Microsoft Visual Basic programming system for Windows, version 3.0



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. 

WORKAROUND 
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 solutions to this dilemma: 

1. A program could 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 function (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 Software Library.



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 function 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 will call these functions: 


   Declare Function Cvs Lib "MBF2IEEE.DLL" (X As String) As Single
   Declare Function Cvd Lib "MBF2IEEE.DLL" (X As String) As Double
   Declare Function Mks Lib "MBF2IEEE.DLL" (X As Single) As String
   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 will return 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 will then convert this value into a 4- or 8-byte 
MBF value and return 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 will not be able to be converted between 
the two formats. If this is the case, a Visual Basic Overflow 
(Error #6) will be generated. This is a trappable error, so handle 
the error accordingly. 

How to Get MBF2IEEE.DLL 
You can find MBF2IEEE.DLL, a self-extracting file, on these services: 

 - Microsoft's World Wide Web site on the Internet
      On the www.microsoft.com home page, click the Support icon
      Click Knowledge Base, and select the product
      Enter kbfile MBF2IEEE.DLL, and click GO!
      Open the article, and click the button to download the file

 - Internet (anonymous FTP)
      ftp ftp.microsoft.com
      Change to the Softlib/Mslfiles folder
      Get MBF2IEEE.DLL

 - The Microsoft Network
      On the Edit menu, click Go To, and then click Other Location
      Type "mssupport" (without the quotation marks)
      Double-click the MS Software Library icon
      Find the appropriate product area
      Locate and Download MBF2IEEE.DLL

 - Microsoft Download Service (MSDL)
      Dial (206) 936-6735 to connect to MSDL
      Download MBF2IEEE.DLL


For additional information about downloading, please see the following
 article in the Microsoft Knowledge Base: 

   ARTICLE-ID: Q119591
   TITLE     : How to Obtain Microsoft Support Files from Online Services


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, you will also find the source code, 
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. It will 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



Additional reference words: BASCOM QBASIC GWBASIC BASICA 3.00 Softlib


S14706


KBCategory: kbprg kbfile kbprb
KBSubcategory: APrgOther


 

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS
PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.  MICROSOFT DISCLAIMS
ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO
EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.  SOME STATES DO NOT ALLOW THE EXCLUSION
OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES
SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1996.


 
2480.2We're real close on this....MSOPW2::TREMELLINGMaking tomorrow yesterday, today!Fri Jan 24 1997 16:1511
    Looks like a winner, thanks for the pointer!  I pulled it from the Web
    site, called it, but received Runtime error 48, 'error loading DLL'.
    
    I fear the DLL was originally for Win3.1 (16 bit), and I'm trying to run 
    it on NT4.0 and 32 bit VB.  One of the other KB articles mentions this
    should work with VB4.0 in 16 bit only code, so I guess I'll install
    that version and see if I have any better luck.
    
    Thanks,
    Darryl
    
2480.3no cigarMSOPW2::TREMELLINGMaking tomorrow yesterday, today!Fri Jan 24 1997 16:5110
    I tried using VB4.0 16 bit and received the infamous "an error has
    occured in your application, close or ignore".  I have the source code
    (in C) but no compiler.  Any chance someone could recompile this for me
    on Win95 or NT?  I'm guessing the DLL was originally created on Win3.1.
    Contact me by mail (msopw::tremelling or [email protected]) if
    you can help.
    
    Thanks,
    Darryl