home *** CD-ROM | disk | FTP | other *** search
- Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!thetimes.pixel.kodak.com!news.kodak.com!news-pen-16.sprintlink.net!news.nysernet.net!news-pull.sprintlink.net!news-in-east.sprintlink.net!news.sprintlink.net!Sprint!144.212.95.13!nntprelay.mathworks.com!news.mathworks.com!news.maxwell.syr.edu!newsfeed.internetmci.com!news.wolsi.com!news.aros.net!news.cs.utah.edu!news.cc.utah.edu!park.uvsc.edu!not-for-mail
- From: knosack@park.uvsc.edu (Kris Nosack)
- Newsgroups: comp.lang.basic.visual.misc,comp.answers,news.answers
- Subject: FAQ: (6/94) comp.lang.basic.visual.* VB/DOS Frequently Asked Questions
- Supersedes: <visual-basic-faq-dos-1-862841465@netcom.com>
- Followup-To: comp.lang.basic.visual.misc
- Date: 5 Jun 1997 14:10:57 -0000
- Organization: Visual Basic FAQ Maintainers
- Lines: 264
- Approved: news-answers-request@MIT.Edu
- Distribution: world
- Expires: 08 Jul 1997 14:10:56 (Z)
- Message-ID: <visual-basic-faq-dos-1-865519856@netcom.com>
- Reply-To: millard@netcom.com (Peter G. Millard)
- NNTP-Posting-Host: park.uvsc.edu
- Summary: Frequently asked questions concerning Visual Basic for DOS.
- Keywords: FAQ VISUAL BASIC DOS
- X-Posting-Frequency: Posted on the 5th of each month.
- X-Content-Currency: This FAQ changes regularly. When a saved or printed copy
- is over 6 months old, please obtain a new one.
- Xref: senator-bedfellow.mit.edu comp.lang.basic.visual.misc:165070 comp.answers:26456 news.answers:104566
-
- Posted-By: auto-faq 3.1.1.2
- Archive-name: visual-basic-faq/dos
-
- Last-Modified: June 10, 1994
-
- VISUAL BASIC FOR DOS (VBDOS)
- Commonly asked Questions & Answers
- Section IX - B
- -----------------------------------
-
- PREFACE:
- This document is a compilation of frequently asked questions and their
- answers about Visual Basic for DOS which have been gathered from the
- comp.lang.basic.visual newsgroup. Although some efforts have been
- made to find obvious errors, there is no guarantee that the information in
- this document is error-free. The FAQ maintainer, or anyone else
- associated with this document, assume NO liability for the content or use
- of this document. If you find any errors, please report them to the address
- given below.
-
- Most FAQs (including this one) are available at the anonymous ftp archive
- site "rtfm.mit.edu". All four parts of the VB FAQ may be found in the
- directory "pub/usenet/news.answers/visual-basic-faq".
-
- You can also have the VB FAQs e-mailed to you by sending a message
- to "mail-server@rtfm.mit.edu" with ONLY the text "send
- usenet/news.answers/visual-basic-faq/*" in the body of the message.
-
- As the FAQ maintainer, I don't have time to explore all of the aspects of
- Visual Basic. I rely on your submissions to improve the quality and
- inclusiveness of this document. If you have found a VB hint, tip, trick,
- work-around, etc., please write it up and send it to me!
- Peter Millardac150@freenet.buffalo.edu - VBDOS FAQ maintainer
-
- Table of Contents:
- 1. How do I use (create) global variables in VBDOS?
- 2. Does VBDOS make standalone .exe files?
- 3. What is the current version of the VBDOS compiler?
- 4. How do I not make a text box beep when I hit the enter key?
- 5. How does Visual Basic handle shelled tasks? How do I find out
- when they are finished.
- 6. How do I break lines of long text into multiple lines of text in
- the msgbox?
- 7. What's the difference between MODAL and MODELESS
- forms?
- 8. When/Why should I use Option Explicit?
- 9. Why doesn't PRINT or CLS from a frm module work?
- 10. How do I invoke FKey traps which won't be triggered by other
- keys which share the same KeyCode?
- 11. How do I boost memory available to VBDOS.EXE (the IDE)?
- 12. My program runs in the IDE, but won't run when compiled??
- 13. MISC. Programming TIPS:
-
- -----------------------------------------------------------------------------
-
- 1. How do I use (create) global variables in VBDOS?
- 1.1. VBDOS provides the user with two types of global variables.
- These are both used in declarations of variables.
-
- To share variables between all subs and functions in a specific
- module, use the SHARED keyword. This makes that specific
- variable global _in that module_. For example:
-
- DIM SHARED CancelFlag AS INTEGER
-
- would make the variable CancelFlag a global variable in that
- module.
-
- To share global variables between separate modules, use the
- COMMON keyword. For example:
-
- COMMON SHARED CancelFlag AS INTEGER
-
- would make the variable global between all modules that this
- common statement appears in, and since we are using the
- SHARED keyword also, this will also be shared in all the subs
- and functions in the modules which this declare statement
- appears. All COMMON statements must be matched between
- modules which the variables should be global in. For example,
- if you have one set of 10 COMMON statements in one module,
- and a different set of 10 COMMON statements in another
- module in the same project, you will get a 'Type Mismatch
- Error'. Make all COMMON blocks identical in all the modules
- in a specific project. (See Misc. Programming Tips Below).
-
- 2. Does VBDOS make standalone .exe files?
- 2.1. VBDOS can compile programs in two different ways (user
- option). It can compile programs to use a RUNTIME file (like
- a DLL) or can be compiled as a standalone .exe file.
-
- 3. What is the current version of the VBDOS compiler?
- 3.1. VBDOS is currently at version 1.0
-
- 4. How do I not make a text box beep when I hit the enter key?
- 4.1. Put "something else" in your _KeyPress event, depending on
- what you really want. This code example makes *nothing*
- happen, for an extended period of time:
-
- Sub Text1_KeyPress (KeyAscii As Integer)
- If KeyAscii = 13 Then '13 is Key_Return
- KeyAscii = 0 '0 (zero) is nothing
- End If
- End Sub
-
- This might not be a very nice thing to do, since your users
- usually have some intention when they press Enter. Usually
- they will want to jump to the next control, like the Tab key
- does. You will then change the line KeyAscii=0 to KeyAscii=9
- (Key_Tab) in the example above.
-
- BTW, you'll also find this in the Microsoft VB
- KnowledgeBase. They add that you should set the MultiLine
- property to False. Of course.
-
- 5. How does Visual Basic handle shelled tasks? How do I find out
- when they are finished.
- 5.1. In VBDOS, all shelled tasks are completed before control
- returns to the program. No tasks are done while the DOS
- command is being executed.
-
- 6. How do I break lines of long text into multiple lines of text in the
- msgbox?
- 6.1. Use the append a chr$(13) to the end of the string to break
- lines into multiple lines. EG:
-
- msg$ = "This is line 1" + chr$(13)
- msg$ = msg$ + "This is line 2"
- MSGBOX msg$
-
- 7. What's the difference between MODAL and MODELESS forms?
- 7.1. Modal forms are forms which require user input before any
- other actions can be taken place. In other words, a modal form
- has exclusive focus until it is dismissed. When showing a
- modal form, the program pauses at the SHOW command until
- the modal form is either hidden or unloaded. The internal
- MSGBOX and INPUTBOX$ forms are examples of modal
- forms. To show a form modally, use the syntax:
- MyForm.SHOW 1
-
- 7.2. Modeless forms are those which are shown but do not require
- immediate user input. Most child forms (in a MDI application)
- are typically modeless. To show a form modeless, use the
- syntax: MyForm.SHOW
-
- 8. When/Why should I use Option Explicit?
- 8.1. Opinions vary greatly on this subject. The main reason to use
- the OPTION EXPLICIT statement at the top of all modules is
- to minimize the amount of bugs introduced into your code by
- misspelling a variable name. Most variants of BASIC
- (including VB) have the capability to create variables 'on the
- fly' (without any declarations). This capability can be a double
- edged sword.
-
- At the minimum, it is suggested to use the DEFINT A-Z
- statement in leu of OPTION EXPLICIT. This statement will
- cause any variables which are created on the fly to be created
- as integers as opposed to single precisions. (Integers take up
- less memory).
-
- The OPTION EXPLICIT statement causes VB to 'disable' it's
- ability to create variables on the fly. Thus, all variables must be
- declared using a DIM or REDIM statement. All variables not
- declared will cause an error when the OPTION EXPLICIT
- statement is used. This will eliminate any bugs when a variable
- is misspelled.
-
- 9. Why doesn't PRINT or CLS from a frm module work?
- 9.1. To print information to the screen bypassing the desktop, the
- commands must be issued from a .BAS module. All
- PRINT/CLS output from a form module is directed to the nul:
- device.
-
- 10. How do I invoke FKey traps which won't be triggered by other keys
- which share the same KeyCode?
- 10.1. To trap the only FKeys in events you need to use a
- combination of the KeyDown, KeyPress, and KeyUp
- events.
-
- The basic concept for this is that _all_ keys trap the UP &
- DOWN events, while only 'printable' characters trigger the
- KeyPress event. Thus, when a character key is pressed, it will
- trigger the KeyDown, the KeyPress, then the KeyUp events (in
- that order). While a FKey (or arrow, or tab, etc...) will trigger
- the KeyDown, then the KeyUp events (in that order).
-
- The following code uses a textbox tag property to decide
- whether a printable character is pressed or not.
-
- SUB Text1_KeyDown()
- Text1.tag = "key"
- END SUB
-
- SUB Text1_KeyPress()
- Text1.tag = ""
- END SUB
-
- SUB Text1_KeyUp()
- IF Text1.tag = "key" then
- '--PUT F-KEY HANDLER HERE----
- ELSE
- '--PUT OTHER KEY HANDLERS HERE----
- END IF
- END SUB
-
- 11. How do I boost memory available to VBDOS.EXE (the IDE)?
- 11.1. Try to have as much EMM available as possible.
- VBDOS.EXE allocates subroutines & functions which are
- < 16K into EMM.
- 11.2. To make more conventional mem availble, use the /S:n
- switch. This will make VBDOS.EXE use a specific
- amount of conventional memory. A good compromise
- between speed & memory is /S:340. The lower the n
- value, the slower the environment runs.
- 11.3. Running out of DGROUP usually causes most 'out of
- memory' errors. Possible causes are:
- 11.3.1.Too many subs & functions exist. Each one takes up
- 46 bytes of DGROUP.
- 11.3.2. Large static arrays. All static arrays are stored in
- DGROUP. If a DIM statement is for a COMMON
- SHARED statement, the array becomes static. Make
- the COMMON SHARED statement appear before
- the DIM statement to make the array Dynamic &
- therefore will not be stored in DGROUP.
- 11.3.3. Variable Overhead. Each var has a 4 byte overhead
- for _each_ module. For multiple modules projects
- which use lots of Global (COMMON) statements,
- this overhead is repeated for _each_ module.
- 11.4. Possible causes for running out conventional memory:
- 11.4.1. Not enough EMM.
- 11.4.2. Subs or functions which exceed 16K.
- 11.4.3. Large arrays. Non-variable length string arrays can
- be stored in EMM using the /ea switch.
-
- 12. My program runs in the IDE, but won't run when compiled??
- 12.1. Arrays are dynamic by default in the IDE, but when they
- are compiled, they are static by default. Therefore, they
- are stored in DGROUP instead of the far heap. Use
- '$DYNAMIC to make all arrays dynamic or use REDIM
- instead of DIM.
- 12.2. Program generates a "program memory overflow" during
- compile. You need to break a single module into multiple
- ones.
-
-
- 13. MISC. Programming TIPS:
- 13.1. When useing the form designed, to continuously draw
- controls of a specific type, hold down the control key
- when clicking on the appropriate control from the tool-
- box.
- 13.2. Use the INCLUDE statement to manage large numbers of
- COMMON SHARED statements, user defined data types,
- or external function DECLARES. To use an include file,
- simply put all the VBDOS statements that will be shared
- into a single file. Save the file as something appropriate.
- (Typical naming convention is to use an extension of .BI
- for basic include files). Then simply insert the line:
- 'INCLUDE: 'foobar.bi'
- into either your .BAS module, or the module level code
- in a form.
-
- --
- Kris Nosack knosack@park.uvsc.edu
-
- >>>---> Be strange, but not a stranger! <---<<<
-