GWBASIC conversion

  • Thread starter Thread starter Al Jones
  • Start date Start date
A

Al Jones

Yep,you read it right, I have the pleasurable task of converting a very
old GWBASIC program to VB, problem is I know GWBASIC and not VB.

I've designed a form with the required fields, given them reasonable names
(cbHurdle, txtName, dtComletionDate, etc). I also taken the original code
and 'plopped' it into a private sub btn_onclick. I've made all the
obvious necessary linguistic changes and globally renamed many of the
variables (VB gets upset over x and y and doesn't seem to know the
difference between c and c$, :) )

Now the question, since the form is in that little black box called
'windows designer code' (yes, I know I can look at it and I have) I
figured that I could 'strC = Form1.cb400Hurdles.value' but not so obvious
- vb complains with 'Reference to non-shared member requires an object
reference' ...??? I would have thought that Form1 was the object .... any
suggestions. If wanted, I can cut & paste code, but would have to snip
the excess and I'm not sure, at this point, that I'd snip the right parts.

Thanks for *any* consideration //al
 
Can you paste in some code as it isn't written which control(s) you are using?
Are you using a combobox?

Dim strC As String = cb400Hurdles.SelectedValue
Dim strC As String = cb400Hurdles.SelectedText
Dim strC As String = cb400Hurdles.SelectedItem
 
That also answers for me whether this is a top or bottom post group <grin>

from the form:
Friend WithEvents lblNumberOfLanes As System.Windows.Forms.Label
Friend WithEvents DateTimePicker1 As
System.Windows.Forms.DateTimePicker
Friend WithEvents btnSubmit As System.Windows.Forms.Button
Friend WithEvents btnQuit As System.Windows.Forms.Button
Friend WithEvents strJobName As System.Windows.Forms.TextBox
Friend WithEvents strLaneWidth As System.Windows.Forms.TextBox
Friend WithEvents strStraightLength As System.Windows.Forms.TextBox
Friend WithEvents strFinishLine As System.Windows.Forms.TextBox
Friend WithEvents strLane1 As System.Windows.Forms.TextBox
Friend WithEvents cb300Hurdles As System.Windows.Forms.CheckBox
Friend WithEvents cb400Hurdles As System.Windows.Forms.CheckBox
Friend WithEvents cb800Relay As System.Windows.Forms.CheckBox
Friend WithEvents strMeasuringPath As System.Windows.Forms.TextBox
Friend WithEvents strNumberOfLanes As
System.Windows.Forms.NumericUpDown
Friend WithEvents strTrackSurface As System.Windows.Forms.TextBox

from the code:
PI = Math.PI
'Print(" DO YOU WANT-")
'INPUT"400 HURDLES";C$
strC = cb400Hurdles.Text ' I know, not a whole lot of
'INPUT"300 HURDLES";strD ' imagination here, but in time...
strD = cb300Hurdles.Text
'INPUT"TRACK COMPANY";E$
strE = strTrackSurface.Text
'INPUT"800 RELAY";strF
strF = cb800Relay.Text
'INPUT"DATE";A$

For the moment the output genned from this is supposed to be going to a
text file,
FileOpen(5, "Darvan.txt", OpenMode.Output)
...
PrintLine(5, "") : PrintLine(5, "") : PrintLine(5, "")
PrintLine(5, "OPTIONAL 1600 WATERFALL START LINE BRK #1" + B1
+ "ARCED ON 30.48 (100') RADIUS")
PrintLine(5, "OPTIONAL 3200 WATERFALL START LINE BRK #1" + B2
+ "ARCED ON 30.48 (100') RADIUS")
but if it's making it there, I can't find the file.

Setting a breakpoint at where I think I enter the buttonClick sub returns
the note that Intellisense could not find the specified location which
suggest to me that the hooks for the sub aren't there.

Hope that gives enough for you to realize I haven't much of an idea about
what I'm doing. //al
 
Try this:

strC = Me.cb400Hurdles.value

Form1 is most likely your main form Class, and you can only call "Shared"
properties and methods directly from the class definition as in your code.
"Me" should be the actual object representing your current Form1 object.

Thanks,
Michael C#
 
BTW, cb400Hurdles appears to be a Checkbox. To retrieve its value, you need
to use something like:

Dim Hurdles400Flag as Boolean = Me.cb400Hurdles.Checked

This assigns the Boolean value (True = checked, False = unchecked) of
cb400Hurdles.Checked to a Boolean variable named Hurdles400Flag.
cb400Hurdles.value will be invalid.

Thanks,
Michael C#
 
VB will automatically create the entry point for the button click event
handler for you. Just double-click the button on the form and you'll be
dropped into the code in the appropriate Sub that will handle the Click
event for the button.

Not sure if you've run into the new functions and methods for creating text
files, but here's a quick example, just in case:

' Putting , False at the end of the following line means it
' will overwrite the file, not append to it. True means it
' will append to the existing file.
Dim myFile As New System.IO.StreamWriter("c:\myFileName.txt", False)
' Use myFile.WriteLine() to write a full line of text that
' ends with a line break. Use myFile.Write to write text
' to the file without a line break at the end
myFile.WriteLine("test")
myFile.Write("xyz")
' This line closes the file
myFile.Close()

There's only a few lines of actual code in there. I added some comments to
help explain it a little better.

Hope it helps
 
Thanks for that tidbit, I knew it was coming as I didn't know how to check
that. Appreciate the afterthought. //al
 
It helps much, are you going to be around when I have to convert this to
printed output, after I get the bugs out of it in the text file. The
whole original code is only about 800 lines of code - but already have
missing labels, and if you said it's spaghetti code, well my italian
friends would object, spaghetti isn't this balled up!

Michael, I very much appreciate you help, thank you //al
 
Michael (or any one), I clipped the entire thread since I'm clightly
changing topics. Thanks to your kind help I have the program as it stands
working correctly (well, as 'correctly as anything converted from
heiroglyphics can be). If I may, I have two more questions (do things
always come in pairs with me - well, normally, yes.)

1) As you'e probably surmised, this is a 'one time' run, each time he
puts in data and prints a report the data is discarded. Is there some
convenient way to 'stash off the data'? There isn't enough information to
require a database and within the next year he may have 50 - 60 sites to
work up so I'm not interested in 'going that way'. However, is it
reasonable to remodel what I have into a "type" and then just save the
data in the structure, or more realistic to just write / read each of the
15 fields? I realize that's strictly an opinion, but I'll accept the
opinion of one who obviously has more experience than I.

2) As I said, this is now to be aimed at the printer, it's correctly
formatted in the file and need to point it toward the printer. I realize
I can just 'print the file' but I'd like to indent away from his left
margin and clean up the pagination (each section will have from 4-9 lines
seperated by blanks lines / labels - I'd like to at least make the next
section appear on a new page when the current page is close to being
full. As I've followed your advice on how to print it with file.writeline
- what's the easiest way to convert this to a printout.

Would also like to direct output to a specific printer (hi choice), but
have found several references on how to do that so I'll see what I can do
there myself. Would also like to allow him to select the font / size if
he doesn't like my choice, and again I've seen examples on how to do
that. Stupid - frustrating - question, why don't the example that show
how to do these things also show how to print with the item selected -
it'd make my questions a lot fewer ...

thanks //al
 
Hi Al,

1) I would probably just create a class that exposes the 15 fields as Public
Properties. You could create objects from the class, and then either: a)
Convert and save/persist the objects as XML or b) Save them off to a
database. A small Access MDB database actually wouldn't be too hard to
create, and all the Data Controls you need can be dragged/dropped right onto
the form. But if you really aren't interested in a database, XML would be
the way to go. XML is fairly simple, but covers a lot of territory -
there's a lot of good info and samples in MSDN Help.

2) Check out the PrinterDialog Common Dialog for choosing a printer. Check
out the Printing.PrintDocument class in MSDN Help. There's a pretty good
example of usage at
http://msdn.microsoft.com/library/d...temdrawingprintingprintdocumentclasstopic.asp.

Not sure what you mean about printing "with the item selected"? Are you
trying to print just one specific item that you've chosen from a list maybe?
Or something else?

Thanks,
Michael C#
 
Al Jones said:
That also answers for me whether this is a top or bottom post group <grin>

Please use bottom posting. A cursory glance at several messages will show
you happen to hit someone using their own preferred style...

Thanks
LFS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top