Computing.Net > Forums > Programming > GWBasic to VB number conversion

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

GWBasic to VB number conversion

Reply to Message Icon

Name: Graham Eady
Date: October 20, 2005 at 02:18:04 Pacific
OS: XP
CPU/Ram: Pentium4 256mb
Comment:

Have a number of GWbasic (BASCICA) programs using single precision number stored in 4 bytes in random files. Am now converting to VB but wish to retain backward compatibility with the old DOS programs. GW stored integers work OK in VB but not the single precision. Does anybody know how to do the conversion or at least how the numbers are stored in GW so I can do my own conversion.




Sponsored Link
Ads by Google

Response Number 1
Name: wizard-fred
Date: October 20, 2005 at 08:11:51 Pacific
Reply:

I think you are looking for the CVx and MKx$ functions for converting MBF variables.


0

Response Number 2
Name: Graham Eady
Date: October 21, 2005 at 07:11:01 Pacific
Reply:

Thanks for the reply I know that MKS$ and CVS handle single precision to and from string format in GWBasic but how do you convert a single precision number stored in a file by GWB using VB to retreive it.

Perhaps the code below will illustrate. Take this bit of GW code

10 OPEN PATH$+"CHEMICAL"FOR RANDOM ACCESS READ WRITE SHARED AS 2 LEN=1200
20 FIELD 2,4 AS ANUMBER$
30 LSET ANUMBER$=MKS$(200)
31 PUT 2,1
32 GET 2,1
33 PRINT CVS(ANUMBER$)
40 END

The number I get back is naturally 200. The following VB code however gives me -6.018531E-34 when addressing the same file

Private Type Chemicals
ANumber As Single
X As String * 1196
End Type
Private Chemicals As Chemicals

Private Sub Command1_Click()
Open Path & "A:CHEMICAL" For Random As 1 Len = 1200
Get 1, 1, Chemicals
Print Chemicals.ANumber
End Sub


That is the problem


0

Response Number 3
Name: wizard-fred
Date: October 21, 2005 at 11:57:22 Pacific
Reply:

You have to the same conversion in VB also MKx$ before writing and CVx after reading.
Also you probably can't define A as NUMBER, it has to be a string that is to be converted.


0

Response Number 4
Name: wizard-fred
Date: October 21, 2005 at 15:14:29 Pacific
Reply:

mks$ and mksmbf$ use different number formats. As does their complements cvs and cvsmbf. It is best to use the manual for examples and make sample programs to test. My response 2 refers to the wrong ones. I haven't programmed in GWBASIC since the compilers were produced. I have just used a little more space and stored all numbers as strings. (easier to visually read the data files, too many versions of BASIC's)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Executable of VC.NET Batch to compare and move...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: GWBasic to VB number conversion

VBA to VB... www.computing.net/answers/programming/vba-to-vb/8140.html

Some similar to vb stuff? www.computing.net/answers/programming/some-similar-to-vb-stuff/5422.html

link excel chart to vb.net www.computing.net/answers/programming/link-excel-chart-to-vbnet/14244.html