Convert Qbasic Programme To Vba

RICKA

New member
Local time
Today, 21:11
Joined
Mar 23, 2005
Messages
27
Does anyone know of a quick way to convert a Qbasic Programme to VBA?

ta Ricka
 
Ricka,

I don't think it should be that tough. VBA "should" be a superset of QBASIC.

Have you tried pasting the code into a module?

Can you post the code?

Wayne
 
Rick,

It's the weekend, we can get stuff done now:

Code:
Private Function CalcQbasic()
90 INPUT "ref "; R$               <-- These should go on a form
100 INPUT "jet model "; jet           We should give them "good" names
110 INPUT "rpm "; E
120 INPUT "head "; H                  We can put the inputs into a table, or at least use
130 INPUT "flow rate "; Q             a form to enter them
131 INPUT "blade no. (3) "; J
132 INPUT "solidity (1.0) "; F
133 INPUT "imp.effy. (.88) "; G
135 K = 0.975                     <-- "Universal constant" Let's give it a meaningful name
220 If jet = 901 Then GoTo 314
223 If jet = 90 Then GoTo 330
250 GoTo 540
314 DR = 3.81                     <-- Each set of these constants should have a real name
315 DT = 9.437                        We'll populate them with a Case statement
316 AR = 0.445
317 AT = 0.1309
318 DB = 5.8
319 DW = 10
320 HR = 2.11
321 HT = 2.33
322 GoTo 590
330 DR = 3.5                      <-- Other half of the Case statement
340 DT = 9.405
350 AR = 0.384
360 AT = 0.1309
370 DB = 5
380 DW = 10
381 HR = 2.16
382 HT = 2.45
383 GoTo 590
590 ard = AR * 57.3               <-- These "dynamic" guys should have real names
591 atd = AT * 57.3                   Now that we can give longer names
595 U = 4
598 A50 = (AR + 2 * AT) / 3       <-- This stuff will convert easily, but it would be
600 AO = A50                          nice to give them "real" names too
605 UR = U / Cos(AR - A50) * 1.05
610 a = DR - UR * Sin(AR)             All of the Math can convert easily
620 c = DR + UR * Sin(AR)
635 UT = U / Cos(A50 - AT) * 0.96
640 B = DT - UT * Sin(AT)
645 d = DT + UT * Sin(AT)
650 P = Q * 4 * Cos(A50) / (B - a) / (B + a) / 3.1416 * 144 / K
655 R = Q * 4 * Cos(A50) / (d - c) / (d + c) / 3.1416 * 144 / K
660 O = 0.5
662 HB = HT + UT / 2 * Cos(AT)
664 HD = HT - UT / 2 * Cos(AT)
666 HA = HR + UR / 2 * Cos(AR)
668 HC = HR - UR / 2 * Cos(AR)
670 L50 = ((B ^ 2 - a ^ 2) * 0.5 + a ^ 2) ^ 0.5
672 M50 = ((d ^ 2 - c ^ 2) * 0.5 + c ^ 2) ^ 0.5
674 HI50 = (L50 - a) / (B - a) * (HB - HA) + HA
676 HE50 = (M50 - c) / (d - c) * (HD - HC) + HC
678 A50 = Atn((M50 - L50) / 2 / (HI50 - HE50))
680 L10 = ((B ^ 2 - a ^ 2) * 0.1 + a ^ 2) ^ 0.5 / 12
685 M10 = ((d ^ 2 - c ^ 2) * 0.1 + c ^ 2) ^ 0.5 / 12
690 A10 = Atn(((L - L10) - (M - M10)) * 6 / Cos(A50) / U) + A50
700 DX = ((DT ^ 2 - DR ^ 2) * O + DR ^ 2) ^ 0.5
705 L = (DX - U * Sin(AO)) / 12
710 M = (DX + U * Sin(AO)) / 12
715 N = E * 3.1416 / 60 * L
720 S = Atn(P / N)
730 U = 12 * (L + M) / 2 * 3.1416 / J * F * Tan((S + T) / 2)
740 V = (1 + 1.25 * Sin(T)) * M * L * 12 / J / U / (M + L)
750 W = 32.2 * H / G / E * 19.1 / ((c ^ 2 + d ^ 2) / 2) ^ 0.5 * 12
760 X = (V + 1) * W
770 Y = Atn(R / (N * M / L - X))
772 If Y < 0 Then Y = 1.5
794 HO = (DX - DR) / (DT - DR) * (HT - HR) + HR
795 HI = HO + U / 2 * Cos(AO)
796 HE = HO - U / 2 * Cos(AO)
800 Z = Atn(W / R)
805 If Y > T + 0.001 Then GoTo 900
806 If Y < T - 0.001 Then GoTo 900
810 If O = 0.5 Then GoTo 990
812 MA = (S + T) * 57.3 / 2
814 CA = (T - S) * 57.3
'
' Now that we're not restricted to the QBASIC interface, should the results go into 
' a table, on the form, or on a report ...
'
820 Y$ = "##.## ###.## ###.## ###.## ###.## ###.## ###.## ###.## ###.## ###.## ###.## "
825 Print USING; Y$; O; L * 12; M * 12; S * 57.3; T * 57.3; U; V; HI; HE; MA; CA
840 If O = 0.5 Then GoTo 842 Else GoTo 860
842 O = 0
844 AO = AR
850 GoTo 700
860 If O = 0 Then GoTo 862 Else GoTo 880
862 O = 0.1
864 AO = A10
870 GoTo 700
880 If O = 0.1 Then GoTo 882 Else GoTo 980
882 O = 1
884 AO = AT
890 GoTo 700
900 T = Y
960 If O = 0.5 Then GoTo 600
970 GoTo 700
980 If c > DB Then LPRINT "zero line outside boss diameter"
982 If d > DW Then LPRINT "tip line outside wear ring"
984 If Y = 1.5 Then LPRINT "angles suspect"
989 End
'
' See above note about the output
'
990 Print "blade number "; J
1010 Print "solidity "; F
1030 Print "impeller efficiency "; G
1050 Print "blockage factor % "; KB
1090 Print "mid dia root ins "; DR
1097 Print "mid height root ins "; HR
1100 Print "mid dia tip ins "; DT
1107 Print "mid height tip ins "; HT
1110 Print "taper angle boss "; ard
1116 Print "taper angle 10% line "; A10 * 57.3
1118 Print "taper angle 50% line "; A50 * 57.3
1120 Print "taper angle tip "; atd
1130 Print "max dia boss ins "; DB
1140 Print "max dia wear ring ins "; DW
1150 Print "Cu3 "; W
1170 Print "stator inlet angle "; Z * 57.3
1190 Print "area d.in d.out b1 b2 bl len cp ht.in ht.out MnAngl camber "
1210 GoTo 812
End Function

Rick, we can make this work, but I'll need some help. Ball's back in your court
for a while.

Wayne
 
Looks like Wayne gave you a great starting point on copying QBASIC over; I would just like to suggest that you may want to think about re-writing the code from scratch mainly because VBA approach is too different from QBASIC, and you would be missing out on many of VBA's features that wasn't available in QBASIC.

One possible stop gap solution is to copy the code into a standard module, break it up into atomic functions and you can then call those functions from appropriate entry point.

HTH.
 
Love those Gotos... I'm sure Wayne's on the course you plotted B.
 
Well it was a rainy, windy miserable day. A good day to play around with Access. Attached is an Access 2007 file. So if you have an earlier version of Access, I expect it won't open. This file is very experimental (primitive). This is one of those personal exploration projects to simply gain some experience with Access 2007. At work we will be upgrading to Office 2007 so I might as well get used to how Access 2007 works.

In short, what I have is a road map, NOT a solution to RICKA QBasic question. Anyway RICKA question really isn't a database type project, but I took a database approach by sticking the variables in a table. This avoids embedding the code in the program and would make it easier for the non-programmer to fix the value of variables.
 

Attachments

steve,
Sorry only using Access 2003 so cannot open your file.

thanks tho

rick
 
Sorry only using Access 2003 so cannot open your file.
See if this works. In theory it has been converted to Access2002/2003. Please be aware that I was doing this to learn Access2007. Consequently, it is not a full solution. I hope what I have done can serve as examples of how to finish what you want. Basically you will need to create additional input boxes and import all your formulas. I made-up imaginary formulas/values, since I had no idea what the real ones did. I hope that this is still useful for you.
--------------------------------------------------------------------
I am taking a look at your database now. Still having issues with getting used to Access2007, but then this is what this exercise is about.

1. Is it your intent to have each test event recorded in the database? If that is the case, you would need one table that holds all your constants. The table that I have in my test database is designed that way. If you intend to record each test, you will need a second table for that.

2. The table that holds your constant values will not need an auto number field. However, the recording table, if one will be developed, will need an auto number field and I would add a date/time stamp field to record each test event.

3. To distinguish computed fields and data entry fields, have them different colors. Also lock the computed fields. See my sample for how that is done.
 

Attachments

Last edited:
The edit button is being uncooperative. I need to quit for a while, so I wanted to relay a couple of points based on my review of your form. The values of R$,E,H,Q,J,F, and J do NOT come from a table so the fields should be unbound. However, if you are recording each test event you will need to save these values to a table. But I can't get into that now as it is quitting time. Take a look at my sample for how some of the variables and constants are set. Got to go.
 
Rick,

I've been on vacation for the last week. I'm surprised that noone has helped
you to evolve this further.

Attached is the VBA version with the MINIMUM amount of changes needed
to make it run.

We can improve on this later if you desire.

Do the results match your old QBASIC ones? I have a standard set of
values for testing.

Wayne
 

Attachments

wayne,
Hope you had a good break.

Fantastic, calculations all come out with the correct values.

Now, i just need to tweak the final output formatting to make it nice and easy to read, could you help with the formatting as although it has been coded in does not seem to be applied in the text box. - changed #'s to 0's works now

Best Regards

RICKA
 
Last edited:
Rick,

Yes, I realized about the "#" versus the "0" issue later. I really just wanted
to get it functioning.

I did it with the MINIMUM amount of changes. If I was using it, I'd redesign
it to take advantage of the Access environment.

1) Store input "variables" in a table
2) Store constants in a table
3) Output to a report

AND, remove all line #s and use If/Then/Else constructs.

I did have a good vacation - 8 days with the internet/newspaper or TV!

Let me know how you're gonna proceed with this.

Wayne
 
Wayne,
I managed to get a workable system with your help, the values don't really need to be stored as this program performs the calculations then they get printed out and used with auto cad to generate a drawing. so all we need to do is print them and store them in a file for reference later (dual purpose as this network is up and down like a yo-yo) :)

thanks again

Rick
 
Wayne,
After all your hard work please see the attached file for some relaxation, should be right up your street.

Rick
 

Attachments

Wayne,
i have another qbasic program to convert, i have used your example as a base but i keep getting overflow - 6 errors can you help?

This code should paste directly over your example to keep things simple.

best regards


Rick
 

Attachments

Rick,

Fascinating little app ... I've only managed to get to level 8. It's much
harder than real pool.

Thanks,
Wayne
 

Users who are viewing this thread

Back
Top Bottom