home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / visual-basic-faq / dos < prev    next >
Encoding:
Internet Message Format  |  1997-06-10  |  13.6 KB

  1. 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
  2. From: knosack@park.uvsc.edu (Kris Nosack)
  3. Newsgroups: comp.lang.basic.visual.misc,comp.answers,news.answers
  4. Subject: FAQ: (6/94) comp.lang.basic.visual.* VB/DOS Frequently Asked Questions
  5. Supersedes: <visual-basic-faq-dos-1-862841465@netcom.com>
  6. Followup-To: comp.lang.basic.visual.misc
  7. Date: 5 Jun 1997 14:10:57 -0000
  8. Organization: Visual Basic FAQ Maintainers
  9. Lines: 264
  10. Approved: news-answers-request@MIT.Edu
  11. Distribution: world
  12. Expires: 08 Jul 1997 14:10:56 (Z)
  13. Message-ID: <visual-basic-faq-dos-1-865519856@netcom.com>
  14. Reply-To: millard@netcom.com (Peter G. Millard)
  15. NNTP-Posting-Host: park.uvsc.edu
  16. Summary: Frequently asked questions concerning Visual Basic for DOS.
  17. Keywords: FAQ VISUAL BASIC DOS
  18. X-Posting-Frequency: Posted on the 5th of each month.
  19. X-Content-Currency: This FAQ changes regularly.  When a saved or printed copy
  20.                     is over 6 months old, please obtain a new one.
  21. Xref: senator-bedfellow.mit.edu comp.lang.basic.visual.misc:165070 comp.answers:26456 news.answers:104566
  22.  
  23. Posted-By: auto-faq 3.1.1.2
  24. Archive-name: visual-basic-faq/dos
  25.  
  26. Last-Modified: June 10, 1994
  27.  
  28.                    VISUAL BASIC FOR DOS (VBDOS)
  29.                 Commonly asked Questions & Answers
  30.                          Section IX - B
  31.                -----------------------------------
  32.  
  33. PREFACE:
  34. This document is a compilation of frequently asked questions and their
  35. answers about Visual Basic for DOS which have been gathered from the
  36. comp.lang.basic.visual newsgroup.   Although some efforts have been
  37. made to find obvious errors, there is no guarantee that the information in
  38. this document is error-free.  The FAQ maintainer, or anyone else
  39. associated with this document, assume NO liability for the content or use
  40. of this document.  If you find any errors, please report them to the address
  41. given below.
  42.  
  43. Most FAQs (including this one) are available at the anonymous ftp archive
  44. site "rtfm.mit.edu".  All four parts of the VB FAQ may be found in the
  45. directory "pub/usenet/news.answers/visual-basic-faq".
  46.  
  47. You can also have the VB FAQs e-mailed to you by sending a message
  48. to "mail-server@rtfm.mit.edu" with ONLY the text "send
  49. usenet/news.answers/visual-basic-faq/*" in the body of the message.
  50.  
  51. As the FAQ maintainer, I don't have time to explore all of the aspects of
  52. Visual Basic.  I rely on your submissions to improve the quality and
  53. inclusiveness of this document.  If you have found a VB hint, tip, trick,
  54. work-around, etc., please write it up and send it to me!
  55.   Peter Millardac150@freenet.buffalo.edu   - VBDOS FAQ maintainer
  56.  
  57. Table of Contents:
  58. 1.   How do I use (create) global variables in VBDOS?
  59. 2.   Does VBDOS make standalone .exe files?
  60. 3.   What is the current version of the VBDOS compiler?
  61. 4.   How do I not make a text box beep when I hit the enter key?
  62. 5.   How does Visual Basic handle shelled tasks? How do I find out
  63.      when they are finished.
  64. 6.   How do I break lines of long text into multiple lines of text in
  65.      the msgbox?
  66. 7.   What's the difference between MODAL and MODELESS
  67.      forms?
  68. 8.   When/Why should I use Option Explicit?
  69. 9.   Why doesn't PRINT or CLS from a frm module work?
  70. 10.  How do I invoke FKey traps which won't be triggered by other
  71.      keys which share the same KeyCode?
  72. 11.  How do I boost memory available to VBDOS.EXE (the IDE)?
  73. 12.  My program runs in the IDE, but won't run when compiled??
  74. 13.  MISC. Programming TIPS:
  75.  
  76. -----------------------------------------------------------------------------
  77.  
  78. 1.   How do I use (create) global variables in VBDOS?
  79.      1.1. VBDOS provides the user with two types of global variables.
  80.           These are both used in declarations of variables.
  81.  
  82.           To share variables between all subs and functions in a specific
  83.           module, use the SHARED keyword. This makes that specific
  84.           variable global _in that module_. For example:
  85.  
  86.                   DIM SHARED CancelFlag AS INTEGER
  87.  
  88.           would make the variable CancelFlag a global variable in that
  89.           module.
  90.  
  91.           To share global variables between separate modules, use the
  92.           COMMON keyword. For example:
  93.  
  94.                  COMMON SHARED CancelFlag AS INTEGER
  95.  
  96.           would make the variable global between all modules that this
  97.           common statement appears in, and since we are using the
  98.           SHARED keyword also, this will also be shared in all the subs
  99.           and functions in the modules which this declare statement
  100.           appears. All COMMON statements must be matched between
  101.           modules which the variables should be global in. For example,
  102.           if you have one set of 10 COMMON statements in one module,
  103.           and a different set of 10 COMMON statements in another
  104.           module in the same project, you will get a 'Type Mismatch
  105.           Error'. Make all COMMON blocks identical in all the modules
  106.           in a specific project. (See Misc. Programming Tips Below).
  107.  
  108. 2.   Does VBDOS make standalone .exe files?
  109.      2.1. VBDOS can compile programs in two different ways (user
  110.           option). It can compile programs to use a RUNTIME file (like
  111.           a DLL) or can be compiled as a standalone .exe file. 
  112.  
  113. 3.   What is the current version of the VBDOS compiler?
  114.      3.1. VBDOS is currently at version 1.0
  115.  
  116. 4.   How do I not make a text box beep when I hit the enter key?
  117.      4.1. Put "something else" in your _KeyPress event, depending on
  118.           what you really want. This code example makes *nothing*
  119.           happen, for an extended period of time:
  120.  
  121.           Sub Text1_KeyPress (KeyAscii As Integer)
  122.               If KeyAscii = 13 Then   '13 is Key_Return
  123.                    KeyAscii = 0  '0 (zero) is nothing
  124.               End If
  125.           End Sub
  126.  
  127.           This might not be a very nice thing to do, since your users
  128.           usually have some intention when they press Enter. Usually
  129.           they will want to jump to the next control, like the Tab key
  130.           does. You will then change the line KeyAscii=0 to KeyAscii=9
  131.           (Key_Tab) in the example above. 
  132.  
  133.           BTW, you'll also find this in the Microsoft VB
  134.           KnowledgeBase. They add that you should set the MultiLine
  135.           property to False. Of course.
  136.  
  137. 5.   How does Visual Basic handle shelled tasks? How do I find out
  138.      when they are finished.
  139.      5.1. In VBDOS, all shelled tasks are completed before control
  140.           returns to the program. No tasks are done while the DOS
  141.           command is being executed.
  142.  
  143. 6.   How do I break lines of long text into multiple lines of text in the
  144.      msgbox?
  145.      6.1. Use the append a chr$(13) to the end of the string to break
  146.           lines into multiple lines. EG:
  147.  
  148.                msg$ = "This is line 1" + chr$(13)
  149.                msg$ = msg$ + "This is line 2"
  150.                MSGBOX msg$
  151.  
  152. 7.   What's the difference between MODAL and MODELESS forms?
  153.      7.1. Modal forms are forms which require user input before any
  154.           other actions can be taken place. In other words, a modal form
  155.           has exclusive focus until it is dismissed. When showing a
  156.           modal form, the program pauses at the SHOW command until
  157.           the modal form is either hidden or unloaded. The internal
  158.           MSGBOX and INPUTBOX$ forms are examples of modal
  159.           forms. To show a form modally, use the syntax:
  160.           MyForm.SHOW 1
  161.  
  162.      7.2. Modeless forms are those which are shown but do not require
  163.           immediate user input. Most child forms (in a MDI application)
  164.           are typically modeless. To show a form modeless, use the
  165.           syntax: MyForm.SHOW
  166.  
  167. 8.   When/Why should I use Option Explicit?
  168.      8.1. Opinions vary greatly on this subject. The main reason to use
  169.           the OPTION EXPLICIT statement at the top of all modules is
  170.           to minimize the amount of bugs introduced into your code by
  171.           misspelling a variable name. Most variants of BASIC
  172.           (including VB) have the capability to create variables 'on the
  173.           fly' (without any declarations). This capability can be a double
  174.           edged sword.
  175.  
  176.           At the minimum, it is suggested to use the DEFINT A-Z
  177.           statement in leu of OPTION EXPLICIT. This statement will
  178.           cause any variables which are created on the fly to be created
  179.           as integers as opposed to single precisions. (Integers take up
  180.           less memory). 
  181.  
  182.           The OPTION EXPLICIT statement causes VB to 'disable' it's
  183.           ability to create variables on the fly. Thus, all variables must be
  184.           declared using a DIM or REDIM statement. All variables not
  185.           declared will cause an error when the OPTION EXPLICIT
  186.           statement is used. This will eliminate any bugs when a variable
  187.           is misspelled.
  188.  
  189. 9.   Why doesn't PRINT or CLS from a frm module work?
  190.      9.1. To print information to the screen bypassing the desktop, the
  191.           commands must be issued from a .BAS module. All
  192.           PRINT/CLS output from a form module is directed to the nul:
  193.           device.
  194.  
  195. 10.  How do I invoke FKey traps which won't be triggered by other keys
  196.      which share the same KeyCode?
  197.      10.1.     To trap the only FKeys in events you need to use a
  198.                combination of the KeyDown, KeyPress, and KeyUp
  199.                events. 
  200.  
  201.           The basic concept for this is that _all_ keys trap the UP &
  202.           DOWN events, while only 'printable' characters trigger the
  203.           KeyPress event. Thus, when a character key is pressed, it will
  204.           trigger the KeyDown, the KeyPress, then the KeyUp events (in
  205.           that order). While a FKey (or arrow, or tab, etc...) will trigger
  206.           the KeyDown, then the KeyUp events (in that order). 
  207.  
  208.           The following code uses a textbox tag property to decide
  209.           whether a printable character is pressed or not.
  210.  
  211.                SUB Text1_KeyDown()
  212.                     Text1.tag = "key"
  213.                END SUB
  214.  
  215.                SUB Text1_KeyPress()
  216.                     Text1.tag = ""
  217.                END SUB
  218.  
  219.                SUB Text1_KeyUp()
  220.                   IF Text1.tag = "key" then
  221.                     '--PUT F-KEY HANDLER HERE----
  222.                   ELSE
  223.                     '--PUT OTHER KEY HANDLERS HERE----
  224.                   END IF
  225.                END SUB
  226.  
  227. 11.  How do I boost memory available to VBDOS.EXE (the IDE)?
  228.      11.1.     Try to have as much EMM available as possible.
  229.                VBDOS.EXE allocates subroutines & functions which are
  230.                < 16K into EMM.
  231.      11.2.     To make more conventional mem availble, use the /S:n
  232.                switch. This will make VBDOS.EXE use a specific
  233.                amount of conventional memory. A good compromise
  234.                between speed & memory is /S:340. The lower the n
  235.                value, the slower the environment runs.
  236.      11.3.     Running out of DGROUP usually causes most 'out of
  237.                memory' errors. Possible causes are:
  238.           11.3.1.Too many subs & functions exist. Each one takes up
  239.                46 bytes of DGROUP.
  240.           11.3.2.   Large static arrays. All static arrays are stored in
  241.                     DGROUP. If a DIM statement is for a COMMON
  242.                     SHARED statement, the array becomes static. Make
  243.                     the COMMON SHARED statement appear before
  244.                     the DIM statement to make the array Dynamic &
  245.                     therefore will not be stored in DGROUP.
  246.           11.3.3.   Variable Overhead. Each var has a 4 byte overhead
  247.                     for _each_ module. For multiple modules projects
  248.                     which use lots of Global (COMMON) statements,
  249.                     this overhead is repeated for _each_ module.
  250.      11.4.     Possible causes for running out conventional memory:
  251.           11.4.1.   Not enough EMM.
  252.           11.4.2.   Subs or functions which exceed 16K.
  253.           11.4.3.   Large arrays. Non-variable length string arrays can
  254.                     be stored in EMM using the /ea switch.
  255.  
  256. 12.  My program runs in the IDE, but won't run when compiled??
  257.      12.1.     Arrays are dynamic by default in the IDE, but when they
  258.                are compiled, they are static by default. Therefore, they
  259.                are stored in DGROUP instead of the far heap. Use
  260.                '$DYNAMIC to make all arrays dynamic or use REDIM
  261.                instead of DIM.
  262.      12.2.     Program generates a "program memory overflow" during
  263.                compile. You need to break a single module into multiple
  264.                ones.
  265.  
  266.      
  267. 13.  MISC. Programming TIPS:
  268.      13.1.     When useing the form designed, to continuously draw
  269.                controls of a specific type, hold down the control key
  270.                when clicking on the appropriate control from the tool-
  271.                box.
  272.      13.2.     Use the INCLUDE statement to manage large numbers of
  273.                COMMON SHARED statements, user defined data types,
  274.                or external function DECLARES. To use an include file,
  275.                simply put all the VBDOS statements that will be shared
  276.                into a single file. Save the file as something appropriate.
  277.                (Typical naming convention is to use an extension of .BI
  278.                for basic include files). Then simply insert the line:
  279.                         'INCLUDE: 'foobar.bi'
  280.                into either your .BAS module, or the module level code
  281.                in a form. 
  282.  
  283. -- 
  284. Kris Nosack      knosack@park.uvsc.edu
  285.  
  286. >>>--->  Be strange, but not a stranger!  <---<<<
  287.