Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Help !Anybody know how to convert old M/S MBF value from Qbasic to VB6

Help !Anybody know how to convert old M/S MBF value from Qbasic to VB6

Help !Anybody know how to convert old M/S MBF value from Qbasic to VB6

I have a old program that used the Microsoft Binary Format (MBF) fuction to hold numeric values.  I'm currrently converting the old Qbasic code to VB6.  It's almost a complete rewrite but I think I can do it, but I can't fiqure out how to convert the MBF values.  The old Qbasic had fuctions like; MKS, CVS, CVD, MKD.  

I went to MSDL and found:
TITLE     :PRB: Converting MBF to IEEE in Visual Basic for Windows

This unfortunatly resulted in a error when I tried to use it.  The error is "Run-Time error '48' File not found: MBF2IEEE.DLL.  I made sure the file was in the correct directory, still no go.  I Finaly figured out that the DLL was written for VB 3.

Does anybodu have any advice on how to convert these old values to something I can use in VB6?

Please Help, thanks

Below is the text form Microsoft explaining how to use the DLL

TITLE     :PRB: Converting MBF to IEEE in Visual Basic for Windows

The information in this article applies to:

- Microsoft Visual Basic programming system for Windows, version 3.0


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.


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

Early versions of Microsoft QuickBASIC and GW-Basic supported only MBF
format. Microsoft Basic Professional Development System (PDS) and Visual
Basic for MS-DOS has functions 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.


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.


This behavior is by design.


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.

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
   ' 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.


Download MBF2IEEE.EXE, a self-extracting file, from the Microsoft Software
Library (MSL) on the following services:

 - CompuServe
      GO MSL
      Search for MBF2IEEE.EXE
      Display results and download

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

 - Internet (anonymous FTP)
      ftp ftp.microsoft.com
      Change to the \softlib\mslfiles directory
      Get MBF2IEEE.EXE

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 for the
.DLL, 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
KBCategory: APrg
KBSubcategory: APrgOther

RE: Help !Anybody know how to convert old M/S MBF value from Qbasic to VB6

If I remember correctly, these functions are converting integers, single, and double precision values into the character representations, without changing the internal binary representation, but I think they byte swap into big endian format.

What I would do is to take your MBF string, and split into a byte array.  Then add the bytes back up, swaping the 0th byte to the least significant position.  Here is a quick representation of the code that might do the job.  This first case is for little endian.

Private Sub MBFConvert()

   Dim IndBytes() As Byte
   Dim MBFData As String
   Dim ix As Integer
   Dim iSLen As Integer
   Dim Total As Double
   Dim power As Integer
   MBFData = "ABCD"
   iSLen = Len(MBFData)
   ReDim IndBytes(iSLen - 1)
   For ix = 1 To iSLen
      IndBytes(ix - 1) = Asc(Mid(MBFData, ix, 1))
   Next ix
   Total = 0
   power = 0
   For ix = 0 To UBound(IndBytes)
      Total = Total + (IndBytes(ix) * (2 ^ power))
      power = power + 8
   Next ix

End Sub

If it turns out that your dealing with big-endian values, then adjust the add up loop to the following:

   Total = 0
   power = 8 * UBound(IndBytes)
   For ix = 0 To UBound(IndBytes)
      Total = Total + (IndBytes(ix) * (2 ^ power))
      power = power - 8
   Next ix

This is fairly brute force but it should be enough to show what's going on.

Good Luck
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein

RE: Help !Anybody know how to convert old M/S MBF value from Qbasic to VB6

Thanks CajunCenturion,

I think this might do it.  I need to implement it aginst my data but it looks good.   

Do you have any additional data for me. maybe somthing I can read or examples.  Just want to fully understand.      

RE: Help !Anybody know how to convert old M/S MBF value from Qbasic to VB6


I guess I spoke too soon, I'm having difficullty understanding.

Here is what I need:

Raw data        should convert to

hffff&ˆ         136.15

×£p=Š‡         127.77

`Âõ(ÜY‡         108.93

if you have an solution I will gladly pay for it NOW

RE: Help !Anybody know how to convert old M/S MBF value from Qbasic to VB6

Can you post the individual ASCII values of the characters from the raw data?

Good Luck
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein

RE: Help !Anybody know how to convert old M/S MBF value from Qbasic to VB6

Thanks for the quick response,

Here are the values

for 136.15
values are

for 127.77
values are
1st - 8
2nd - 215
3rd - 163
4th - 112
5th - 61
6th - 138
7th - 127
8th - 135

for 108.93
values are

RE: Help !Anybody know how to convert old M/S MBF value from Qbasic to VB6

have you considered an approach to write (simple) convertor in old BASIC that understands these numbers to say ASCII?
So you convert all data at once and have no problems once and for all.

RE: Help !Anybody know how to convert old M/S MBF value from Qbasic to VB6

Microsoft did a DLL converter, but it was written as 16-bit. The source cod eis available from MS if you can re-compile as a 32-bit DLL it may help. Have a look at KB 140520:

If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'

RE: Help !Anybody know how to convert old M/S MBF value from Qbasic to VB6

I have not tried myself but here is a link to a third-party DLL for converting numbers from MBF to IEEE formats.

RE: Help !Anybody know how to convert old M/S MBF value from Qbasic to VB6

Thanks guys the 32-bit DLL works great. It even has fuctions to convert the data at the field definition level.

Thanks again.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close