Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VB 5 screen display

38 views
Skip to first unread message

jgro...@gmail.com

unread,
May 1, 2013, 10:07:36 PM5/1/13
to
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

unread,
May 1, 2013, 10:18:47 PM5/1/13
to
jgro...@gmail.com pretended :
> 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

unread,
May 2, 2013, 1:34:37 AM5/2/13
to
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

Deanna Earley

unread,
May 2, 2013, 3:49:01 AM5/2/13
to
On 02/05/2013 03:07, jgro...@gmail.com wrote:
> 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 (dee.e...@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

unread,
May 2, 2013, 4:00:34 AM5/2/13
to
<jgro...@gmail.com> wrote in message
news:48920a48-d284-4880...@googlegroups.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

unread,
May 2, 2013, 6:11:08 AM5/2/13
to
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

Michael Cole

unread,
May 2, 2013, 8:30:08 PM5/2/13
to
Justin Groshan formulated the question :
> Michael Cole <inv...@microsoft.com> wrote:
>> jgro...@gmail.com pretended :
>>> 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.


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

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

> I recall something that said debug.print would not work in vb5.

It definately does. Use it and see. Experiment.

--
Michael Cole


Justin Groshan

unread,
May 2, 2013, 11:06:32 PM5/2/13
to
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

unread,
May 2, 2013, 11:17:08 PM5/2/13
to
jgroshan

Correction. That is console.writeline method.

Deanna Earley

unread,
May 3, 2013, 4:19:59 AM5/3/13
to
On 03/05/2013 04:06, Justin Groshan wrote:
> 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 :)

DaveO

unread,
May 3, 2013, 4:30:33 AM5/3/13
to

"Justin Groshan" <jgro...@pacbell.net> wrote in message
news:1550109733389243709.452636jgroshan-
<snip>
> 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

unread,
May 3, 2013, 10:29:13 AM5/3/13
to
--
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.

Justin Groshan

unread,
May 3, 2013, 10:29:14 AM5/3/13
to
jgroshan
Thank you very much, good advice

DaveO

unread,
May 3, 2013, 10:53:31 AM5/3/13
to

"Justin Groshan" <jgro...@pacbell.net> wrote in message
news:1048416113389283972.706...@news.giganews.com...
> "DaveO" <d...@dial.pipex.com> wrote:
>> "Justin Groshan" <jgro...@pacbell.net> wrote in message
>> 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

unread,
Jun 7, 2013, 1:41:24 PM6/7/13
to
> 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

unread,
Jun 10, 2013, 4:15:09 AM6/10/13
to

"Theo Tress" <r...@online.de> wrote in message news:kot60i$pcc$1...@online.de...
>> 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

unread,
Jun 11, 2013, 12:01:27 PM6/11/13
to
> 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.


0 new messages