Discussion:
VB 5 screen display
(too old to reply)
j***@gmail.com
2013-05-02 02:07:36 UTC
Permalink
How do I display the answer to a math problem on the screen when using VB 5? I am looking for something similar to the print statement in Basic.
Michael Cole
2013-05-02 02:18:47 UTC
Permalink
Post by j***@gmail.com
How do I display the answer to a math problem on the screen when using VB 5?
I am looking for something similar to the print statement in Basic.
If you are talking IDE, Debug.Print will print to the Immediate window.

If you are talking a console-type app, then you should be looking at
the WriteConsole API

Public Declare Function WriteConsole Lib "kernel32" Alias
"WriteConsoleA" (ByVal hConsoleOutput As Long, lpBuffer As Any, ByVal
nNumberOfCharsToWrite As Long, lpNumberOfCharsWritten As Long,
lpReserved As Any) As Long
--
Michael Cole
Justin Groshan
2013-05-02 05:34:37 UTC
Permalink
Post by Michael Cole
Post by j***@gmail.com
How do I display the answer to a math problem on the screen when using
VB 5? > I am looking for something similar to the print statement in Basic.
If you are talking IDE, Debug.Print will print to the Immediate window.
If you are talking a console-type app, then you should be looking at the WriteConsole API
Public Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA"
(ByVal hConsoleOutput As Long, lpBuffer As Any, ByVal
nNumberOfCharsToWrite As Long, lpNumberOfCharsWritten As Long, lpReserved As Any) As Long
--
I know virtually nothing about vb. What I am trying to accomplish is to
write simple programs involving math problems and displaying the answer on
the screen as you would in Basic with a print statement. Assume the
variable is x, then the answer in basic would be ? X. How would I
accomplish the same thing In Vb5, the only version I have access to.? I
recall something that said debug.print would not work in vb5. Any help
would be appreciated.


jgroshan
Michael Cole
2013-05-03 00:30:08 UTC
Permalink
Post by Justin Groshan
Post by Michael Cole
Post by j***@gmail.com
How do I display the answer to a math problem on the screen when using
VB 5? > I am looking for something similar to the print statement in Basic.
If you are talking IDE, Debug.Print will print to the Immediate window.
If you are talking a console-type app, then you should be looking at the WriteConsole API
Public Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA"
(ByVal hConsoleOutput As Long, lpBuffer As Any, ByVal
nNumberOfCharsToWrite As Long, lpNumberOfCharsWritten As Long, lpReserved As Any) As Long
OK, firstly, don't start your message after a double-dash - that marks
it as a signature for some newsreaders, and it makes it difficult to
read and reply to.
Post by Justin Groshan
I know virtually nothing about vb.
Then that would be your major problem. Get hold of a book on it, read
the help file, search the internet, something.
Post by Justin Groshan
What I am trying to accomplish is to
write simple programs involving math problems and displaying the answer on
the screen as you would in Basic with a print statement. Assume the
variable is x, then the answer in basic would be ? X. How would I
accomplish the same thing In Vb5, the only version I have access to.?
If you are more used to Basic (rather than Visual Basic) then as MikeS
said, get a copy of QBasic - its free and downloadable.
Post by Justin Groshan
I recall something that said debug.print would not work in vb5.
It definately does. Use it and see. Experiment.
--
Michael Cole
Justin Groshan
2013-05-03 03:06:32 UTC
Permalink
Post by Justin Groshan
Post by Michael Cole
Post by j***@gmail.com
How do I display the answer to a math problem on the screen when using
VB 5? > I am looking for something similar to the print statement in Basic.
Post by Michael Cole
If you are talking IDE, Debug.Print will print to the Immediate window.
If you are talking a console-type app, then you should be looking at the >>
WriteConsole API
Public Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA"
(ByVal hConsoleOutput As Long, lpBuffer As Any, ByVal
nNumberOfCharsToWrite As Long, lpNumberOfCharsWritten As Long,
lpReserved As >> Any) As Long
OK, firstly, don't start your message after a double-dash - that marks it
as a signature for some newsreaders, and it makes it difficult to read and reply to.
Post by Justin Groshan
I know virtually nothing about vb.
Then that would be your major problem. Get hold of a book on it, read
the help file, search the internet, something.
Post by Justin Groshan
What I am trying to accomplish is to
write simple programs involving math problems and displaying the answer on
the screen as you would in Basic with a print statement. Assume the
variable is x, then the answer in basic would be ? X. How would I
accomplish the same thing In Vb5, the only version I have access to.?
If you are more used to Basic (rather than Visual Basic) then as MikeS
said, get a copy of QBasic - its free and downloadable.
Post by Justin Groshan
I recall something that said debug.print would not work in vb5.
It definately does. Use it and see. Experiment.
--
Thank you for your answers to my question. It's obvious that I do not
understand visual basis. I have attempted to find the answer to my question
without success. I probably don't know what to look for. I did find
debug.print in a book on VBA and I attempted it in vb5 with no success. I
will try it again. For vb6 and later editions I was able to find
write.console, however I have not tried it in vb5. I found a site in
Microsoft to download free versions of Visual Basic. I have quick basic and
I am operating it in virtual xp on my windows 7 64 bit computer. My
concern is that ultimately I will have to load windows 8. I understand that
dos programs will not run on windows 8. I have basic programs on my ipad. I
would like to be able to use vba. Just before writing this post I found in
a book that I just bought to learn vb5 the code to write z = x+y, define z
as a string and display it in a text box. This was purely by accident, I
looked under the section on code and found what I just described. There was
no reference in the index.

jgroshan
Justin Groshan
2013-05-03 03:17:08 UTC
Permalink
Post by Justin Groshan
Post by Michael Cole
Post by j***@gmail.com
How do I display the answer to a math problem on the screen when using
VB 5? > I am looking for something similar to the print statement in Basic.
Post by Michael Cole
If you are talking IDE, Debug.Print will print to the Immediate window.
If you are talking a console-type app, then you should be looking at the >>
WriteConsole API
Public Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA"
(ByVal hConsoleOutput As Long, lpBuffer As Any, ByVal
nNumberOfCharsToWrite As Long, lpNumberOfCharsWritten As Long,
lpReserved As >> Any) As Long
OK, firstly, don't start your message after a double-dash - that marks it
as a signature for some newsreaders, and it makes it difficult to read and reply to.
Post by Justin Groshan
I know virtually nothing about vb.
Then that would be your major problem. Get hold of a book on it, read
the help file, search the internet, something.
Post by Justin Groshan
What I am trying to accomplish is to
write simple programs involving math problems and displaying the answer on
the screen as you would in Basic with a print statement. Assume the
variable is x, then the answer in basic would be ? X. How would I
accomplish the same thing In Vb5, the only version I have access to.?
If you are more used to Basic (rather than Visual Basic) then as MikeS
said, get a copy of QBasic - its free and downloadable.
Post by Justin Groshan
I recall something that said debug.print would not work in vb5.
It definately does. Use it and see. Experiment.
--
jgroshan

Correction. That is console.writeline method.
DaveO
2013-05-03 08:30:33 UTC
Permalink
"Justin Groshan" <***@pacbell.net> wrote in message
news:1550109733389243709.452636jgroshan-
<snip>
Post by Justin Groshan
Correction. That is console.writeline method.
Further Correction: "Console.Writeline" is not to be found in VB6 but in
later "versions" which to confuse you even more are nothing like VB6 or
earlier. Microsoft thought that programmers were so stupid they wouldn't
notice that the new VBs (after Version 6) were completely different to VB6
and earlier insofar as VB6 and earlier used the COM interface to Windows
while VB7 and beyond were more OOP and relied on .NET to work.
To address your points however, Debug.Print does work in VB5 but you may be
looking in the wrong place for what it "prints", Debug.Pring sends the
output to the Immediate window and therefore does only work when run in the
development environment, in VB6 the Hotkey for it is Ctrl+G or press the
toolbar button with an icon like a window with a yellow exclamation mark, it
should be much the same in VB5.
You can also send the output to a textbox as you've found or to a label, the
textbox has the advantage of being able to have the content selected and
then copied to the clipboard.
Another possiblity somewhere inbetween textboxes and console output is the
treat the form as an output window as Deanna implied: Have a window with no
controls on it and set the AutoRedraw option to True and then you can print
to that window just using the Print command.
Regards
DaveO
Justin Groshan
2013-05-03 14:29:13 UTC
Permalink
Post by DaveO
news:1550109733389243709.452636jgroshan-
<snip>
Post by Justin Groshan
Correction. That is console.writeline method.
Further Correction: "Console.Writeline" is not to be found in VB6 but in
later "versions" which to confuse you even more are nothing like VB6 or
earlier. Microsoft thought that programmers were so stupid they wouldn't
notice that the new VBs (after Version 6) were completely different to VB6
and earlier insofar as VB6 and earlier used the COM interface to Windows
while VB7 and beyond were more OOP and relied on .NET to work.
To address your points however, Debug.Print does work in VB5 but you may be
looking in the wrong place for what it "prints", Debug.Pring sends the
output to the Immediate window and therefore does only work when run in the
development environment, in VB6 the Hotkey for it is Ctrl+G or press the
toolbar button with an icon like a window with a yellow exclamation mark, it
should be much the same in VB5.
You can also send the output to a textbox as you've found or to a label, the
textbox has the advantage of being able to have the content selected and
then copied to the clipboard.
Another possiblity somewhere inbetween textboxes and console output is the
treat the form as an output window as Deanna implied: Have a window with no
controls on it and set the AutoRedraw option to True and then you can print
to that window just using the Print command.
Regards
DaveO
--
jgroshan
I will attempt to implement your suggestion. Now I need to find the
AutoRedraw option. Where do I look?
Thank you very much. Thank everyone who answered my question.
DaveO
2013-05-03 14:53:31 UTC
Permalink
Post by Justin Groshan
Post by DaveO
news:1550109733389243709.452636jgroshan-
<snip>
--
jgroshan
I will attempt to implement your suggestion. Now I need to find the
AutoRedraw option. Where do I look?
Thank you very much. Thank everyone who answered my question.
In the IDE select the form then open the properties page for the form
(Hotkey: F4 [*]), the various values you can set at design time are listed
here. It's been a long time since I looked at VB5 but I have no reason to
think AutoRedraw was new to VB6.

If you are running calculations then you'll probably want to keep everything
aligned so change the form font to a fixed pitch typeface such as Courier or
Lucidia Console. The form font is also set on the properties page.

It would be in your interest to spend a while mucking about with the IDE
just to see what's there and what you can do before you start writing any
code.

Regards
DaveO.

[*] That is for VB6, it's probably, but not definitely the same for VB5
Theo Tress
2013-06-07 17:41:24 UTC
Permalink
Post by Justin Groshan
I will attempt to implement your suggestion. Now I need to find the
AutoRedraw option. Where do I look?
Justin, I guess you don't have to care about AutoRedraw. The difference
between good old Basic's PRINT statement and VB5's Print Method is that
there PRINT directed its output to the screen where VB5's Print directs
output to the object in which the Print Statement is executed, and one of
those objects is a form - a window within Windows.

Therefore, simply open your VB5,
- select to create a Standard Exe and the IDE will present a new project
with one form
- doubleclick the form and the IDE opens the code window for that form
- in the right listbox where "Load" is shown select DblClick
- in the Private Sub Form_Dblclick enter a new line "PRINT Time$" , this
will print the time onto the form whenever you doubleclick it
- press F5 to run the program
-doubleclick the form/window
and you'll see how Print works in VB5/6
DaveO
2013-06-10 08:15:09 UTC
Permalink
Post by Theo Tress
Post by Justin Groshan
I will attempt to implement your suggestion. Now I need to find the
AutoRedraw option. Where do I look?
Justin, I guess you don't have to care about AutoRedraw. The difference
between good old Basic's PRINT statement and VB5's Print Method is that
there PRINT directed its output to the screen where VB5's Print directs
output to the object in which the Print Statement is executed, and one of
those objects is a form - a window within Windows.
You can leave the AutoRedraw as False but if you do you MUST put code in the
forms Paint subroutine to print everything otherwise everytime the form is
covered by another form or is moved off the screen the printed information
will be lost. (At least that's the case in VB6 but I'm pretty sure it's the
same for VB5).

DaveO
Theo Tress
2013-06-11 16:01:27 UTC
Permalink
Post by DaveO
You can leave the AutoRedraw as False but if you do you MUST put code in
the forms Paint subroutine to print everything otherwise everytime the
form is covered by another form or is moved off the screen the printed
information will be lost. (At least that's the case in VB6 but I'm pretty
sure it's the same for VB5).
It's the same, but his questions shows that he has a fundamental problem
understanding VB printing, how it works. I had the same problems wehn
running VB3 for the first time.

When he wants to print some more data into a form's window sooner or later
he will reach the bottom border and then he has much more problems than
redrawing.

Deanna Earley
2013-05-03 08:19:59 UTC
Permalink
Post by Justin Groshan
Thank you for your answers to my question. It's obvious that I do not
understand visual basis. I have attempted to find the answer to my question
without success. I probably don't know what to look for. I did find
debug.print in a book on VBA and I attempted it in vb5 with no success. I
will try it again. For vb6 and later editions I was able to find
write.console, however I have not tried it in vb5. I found a site in
Microsoft to download free versions of Visual Basic. I have quick basic and
I am operating it in virtual xp on my windows 7 64 bit computer. My
concern is that ultimately I will have to load windows 8. I understand that
dos programs will not run on windows 8. I have basic programs on my ipad. I
would like to be able to use vba. Just before writing this post I found in
a book that I just bought to learn vb5 the code to write z = x+y, define z
as a string and display it in a text box. This was purely by accident, I
looked under the section on code and found what I just described. There was
no reference in the index.
You seem to have a very mismatched understanding of the languages and
code and confusing everything.

A few basics (no pun intended):

* Basic is a relatively simple language and syntax used by multiple
different languages.

* QBasic is a DOS interpreter (and sometimes compiler) for Basic.
It allows console output (CLI), and with effort, a text based UI.

* VBDos adds "flashy" TUI and event driven programming to DOS applications.

* Visual Basic (3, 4, 5, 6, or "classic") is a Windows GUI development
tool. This involves windows, controls, text boxes, buttons and the
mouse, and is still event driven.
While it's possible to create Win32 CLI applications, it's not supported
natively.

* VBA is a version of the Visual Basic (classic) IDE and engine embedded
into another application, primarily Office. It has no use outside this
environment and can not create CLI applications (or standalone GUI
applications).

* VB.Net is the latest incarnation of the "Basic" environment from
Microsoft and has full support for Win32 CLI and GUI applications.

You seem to be trying to use VB5 to create a CLI application which isn't
going to happen until you learn a lot more (fact, no offence meant,
programming is hard).

As you're working in the world of Windows, it is FAR easier to create a
full Win32 GUI application based on text boxes, buttons, labels, etc.
With VB5, this is SOO easy as that's what its entire design is geared
around. Try this as a starter:

Create a new blank project in VB5, Open the default form, add two text
boxes, a button and a label.
Double click the button and add this between the two lines it added:

Dim Value1 As Single
Dim Value2 As Single
Dim Result as Single
Value1 = Val(Text1.Text) 'Get the number in text box 1
Value2 = Val(Text2.Text) 'Get the number in text box 2
Result = Value1 * Value2 'Simple multiplication to get a result
Label1.Caption = CStr$(Result) 'Put the result in the label

With the help of the many tutorials available online, I'm sure you can
expand on this very basic (pun intended this time :p) multiplication
calculator to do what you want.

Good luck, and just for clarity, if you're learning from scratch, ditch
VB5 and all VB Classics. Go straight to VB.Net. There is no point
learning a 16 year old language and IDE. If you're doing a college
course, then tell the college to ditch VB5 :)
--
Deanna Earley (***@icode.co.uk)
iCatcher Development Team
http://www.icode.co.uk/icatcher/

iCode Systems

(Replies direct to my email address will be ignored. Please reply to the
group.)
Justin Groshan
2013-05-03 14:29:14 UTC
Permalink
Post by Deanna Earley
Post by Justin Groshan
Thank you for your answers to my question. It's obvious that I do not
understand visual basis. I have attempted to find the answer to my question
without success. I probably don't know what to look for. I did find
debug.print in a book on VBA and I attempted it in vb5 with no success. I
will try it again. For vb6 and later editions I was able to find
write.console, however I have not tried it in vb5. I found a site in
Microsoft to download free versions of Visual Basic. I have quick basic and
I am operating it in virtual xp on my windows 7 64 bit computer. My
concern is that ultimately I will have to load windows 8. I understand that
dos programs will not run on windows 8. I have basic programs on my ipad. I
would like to be able to use vba. Just before writing this post I found in
a book that I just bought to learn vb5 the code to write z = x+y, define z
as a string and display it in a text box. This was purely by accident, I
looked under the section on code and found what I just described. There was
no reference in the index.
You seem to have a very mismatched understanding of the languages and
code and confusing everything.
* Basic is a relatively simple language and syntax used by multiple different languages.
* QBasic is a DOS interpreter (and sometimes compiler) for Basic.
It allows console output (CLI), and with effort, a text based UI.
* VBDos adds "flashy" TUI and event driven programming to DOS applications.
* Visual Basic (3, 4, 5, 6, or "classic") is a Windows GUI development
tool. This involves windows, controls, text boxes, buttons and the mouse,
and is still event driven.
While it's possible to create Win32 CLI applications, it's not supported natively.
* VBA is a version of the Visual Basic (classic) IDE and engine embedded
into another application, primarily Office. It has no use outside this
environment and can not create CLI applications (or standalone GUI applications).
* VB.Net is the latest incarnation of the "Basic" environment from
Microsoft and has full support for Win32 CLI and GUI applications.
You seem to be trying to use VB5 to create a CLI application which isn't
going to happen until you learn a lot more (fact, no offence meant, programming is hard).
As you're working in the world of Windows, it is FAR easier to create a
full Win32 GUI application based on text boxes, buttons, labels, etc.
With VB5, this is SOO easy as that's what its entire design is geared
Create a new blank project in VB5, Open the default form, add two text
boxes, a button and a label.
Dim Value1 As Single
Dim Value2 As Single
Dim Result as Single
Value1 = Val(Text1.Text) 'Get the number in text box 1
Value2 = Val(Text2.Text) 'Get the number in text box 2
Result = Value1 * Value2 'Simple multiplication to get a result
Label1.Caption = CStr$(Result) 'Put the result in the label
With the help of the many tutorials available online, I'm sure you can
expand on this very basic (pun intended this time :p) multiplication
calculator to do what you want.
Good luck, and just for clarity, if you're learning from scratch, ditch
VB5 and all VB Classics. Go straight to VB.Net. There is no point
learning a 16 year old language and IDE. If you're doing a college
course, then tell the college to ditch VB5 :)
--
jgroshan
Thank you very much, good advice
Deanna Earley
2013-05-02 07:49:01 UTC
Permalink
Post by j***@gmail.com
How do I display the answer to a math problem on the screen when using VB 5? I am looking for something similar to the print statement in Basic.
Use a label or a text box on the form.
Alternatively, the .Print statement (but by default that is only on
screen until a redraw).
--
Deanna Earley (***@icode.co.uk)
iCatcher Development Team
http://www.icode.co.uk/icatcher/

iCode Systems

(Replies direct to my email address will be ignored. Please reply to the
group.)
MikeS
2013-05-02 08:00:34 UTC
Permalink
Post by j***@gmail.com
How do I display the answer to a math problem on the screen when using VB
5? I am looking for something similar to the print statement in Basic.
You can use VB5 as a console program but as its name implies it is really
designed for visual programming, ie with screen display in windows. VB5
makes simple programming this way a trivial task and there are plenty of
sites with free tutorials, code examples, etc. If you really don't want to
do that you would be better off finding a download of Quickbasic or one of
the many free equivalents like Qbasic.
ralph
2013-05-02 10:11:08 UTC
Permalink
Post by j***@gmail.com
How do I display the answer to a math problem on the screen
when using VB 5? I am looking for something similar to the print
statement in Basic.
In addition you wll need to read this:
http://floating-point-gui.de/

And probably several articles like this ...
http://www.vb-helper.com/howto_formatnumber.html
since content (expected values) and presentation will be slightly
different on occasion.

-ralph
Continue reading on narkive:
Loading...