allanswers.org - FAQ: (8/95) comp.lang.basic.visual.* VB/Win Frequently Asked Questions

 Home >  Programmingvisual-basic-faq >

FAQ: (8/95) comp.lang.basic.visual.* VB/Win Frequently Asked Questions

Section 1 of 4 - Prev - Next
All sections - 1 - 2 - 3 - 4


Posted-By: auto-faq 3.1.1.2
Archive-name: visual-basic-faq/windows

Last-modified: 22-Aug-95

Covers VB 4.0 (briefly)

*** ATTENTION ***
A greatly expanded and updated version of this FAQ can now be found on the
WWW at http://home.sol.no/jansh/vb/default.htm - you are strongly encouraged
to refer to the WWW version.  The WWW version may be "ported" to text and
posted to the VB newsgroups, but there are no definate plans to do this at
this time.

Please send all feedback on this document to jansh@online.no (Jan S. Haugland)
Please don't send VB questions to the FAQ maintainers' private email account.
   

                   VISUAL BASIC FOR WINDOWS (VB/Win)
                 Frequently asked Questions & Answers
                            Section IX - B
   
   
   The following symbols indicates new & updated topics:
   
   [++] means topic is updated in this issue
   [**] means topic is new in this issue
   
   Hope this makes it easier for Our Regular Readers   ;-)
   
   
   
   TABLE OF CONTENTS:
   ******************
   
   A. PREFACE
   1. About this document
   2. Where to get the VB/Win FAQ [++]
   3. Kudos & comments
   
   B. GENERAL VISUAL BASIC QUESTIONS
   1. Does VB/Win make standalone .EXE files?
   2. What is the current version of Visual Basic for Windows? [++]
   3. Where can I get updated VB and other Microsoft files?
   4. Help! I am lost on ftp.microsoft.com.
   5. Where can I get good up-to-date information about VB? [++]
   6. WWW pages for VB! [**]
   7. Are there any examples of commercial applications built using
       Visual Basic?
   8. Limits of VB?
   
   C. COMMON VISUAL BASIC PROGRAMMING QUESTIONS
   1. What's the difference between MODAL and MODELESS forms? [++]
   2. When/Why should I use Option Explicit?
   3. Why does everybody say I should save in TEXT not BINARY?
   4. Is the Variant type slower than using other variable types?
   5. How do I make a text box not beep but do something else when I
       hit the Enter key?
   6. How do I implement an incremental search in list/dir/combo/file
       boxes?
   7. How do I get the Tab key to be treated like a normal character?
   8. How do I make an animated icon for my program?
   9. What is passing by reference?
   10. I get a "file not found" error on the IIF function when I
       distribute by program. Uh?
   11. Is there any way to pass a variable to a form apart from using
       global variables?
   12. How should dates be implemented so they work with other
       language and country formats?
   13. Can a VB application be an OLE server?
   14. How do I dial a phone number without using the MSCOMM VBX?
   15. I have [several] megabytes of memory. Why do I get an "out of
       memory" error? [++]
   16. How do I mimic a toggle button? [++]
   17. How do I get my application on top?
   18. Is there a way to break long lines in VB code?
   19. How do I remove/change the picture property of a control at
       design time?
   20. Is a [foo] VBX/DLL available as shareware/freeware?
   21. How do I make my applications screen-resolution independent?
   22. How do I do Peek and Poke and other low-level stuff? [++]
   23. Why doesn't "my string" & Chr$(13) do what I want?
   24. How do I prevent multiple instances of my program?
   25. How do I implement an accelerator key for a text box?
   26. How do I force a file dialogue box to reread the currect disk?
   27. How do I get the number of free bytes on a disk? [++]
   28. Data Control missing from toolbox when I use VB under NT 3.5.
       Huh?
   
   D. ADVANCED VISUAL BASIC PROGRAMMING ISSUES
   1. How do I tell when an application executed using the SHELL
       command is finished?
   2. How do I access C style strings?
   3. How can I change the printer Windows uses in code without using
       the print common dialog? How can I change orientation?
   4. Any tips for speeding up VB?
   5. How do I speed up control property access?
   6. How much gain in performance will I get if I write my number
       crunching routines in C instead of Visual Basic?
   7. How do you make a TEXTBOX read only? Or, how do I prevent the
       user from changing the text in a TEXTBOX?
   8. How can I create a VBX?
   9. How do you change the system menu (on the Control-Menu Box)?
   10. How do I play MID, WAV or other multimedia files?
   11. How can I call a 'hidden' DOS program from VB?
   12. How do I do drag & drop between applications?
   13. How do I use GetPrivateProfileString to read from INI files?
   14. How do I implement Undo?
   15. How do I create a window with a small title bar as in a
       floating toolbar?
   16. What is Pseudocode?
   17. Does VB support pointers to functions?
   18. How do I program the Novell NetWare API from VB?
   19. Visual Basic 4 news [**]
   20. How do you change the icon and otherwise manipulate the DOS
       box?
   21. How do I make the mouse cursor invisible/visible?
   22. How do I create controls dynamically (at run-time)?
   23. How do I set the Windows wallpaper at runtime?
   24. How do I call help files from a VB program? [**]
   
   E. CALLING THE WINDOWS API AND DLLs IN GENERAL
   1. What is the Windows API?
   2. How do I call a DLL?
   3. What about DLL calls that require callbacks?
   4. Tips for calling DLLs (such as the Windows API)
   
   F. VISUAL BASIC AND DATABASES
   1. Why can't I use an index with my VB accessed database?
   2. "Can't find installable ISAM" or Why does my compiled VB
       database app generate an error when it ran just fine in the
       design environment?
   3. Is the Access Engine and Visual Basic Pro good enough for
       database work?
   4. How do you avoid the "Invalid use of null" error when reading
       null values from a database?
   5. What is "NULL"?
   6. How can I access a record by record number?
   7. How about Access 2.0 compatibility?
   8. Tips for VB database programming:
   9. How come I get a "No Current Record" error when I use a a Data
       Control on an empty table?
   10. How can I speed up my VB database application?
   11. How do I get a bitmap picture in a field in an Access
       database?
   12. What is "Reserved Error -1209"?
   13. "Cannot perform operation. illegal.." with Paradox 3.5
       table(s)
   14. I'm getting error message "Reserved Error [-nnnn] ("There is
       no message for this error")" from Jet Engine 2.0. Huh?
   15. Why do I get "object not an array" when I try reference the
       fields of a global object variable which I have set to a table?
   16. Steps for securing an Access 2.0 database [**]
   
   G. DISTRIBUTING VISUAL BASIC APPLICATIONS
   1. What are some tips for using Setup Wizard?
   2. Are there restrictions on what I can distribute with my VB
       program?
   3. What alternatives to setup wizard do I have?
   4. Do I need to worry about users who have Progman replacements
       such as Norton Desktop and PC Tools?
   5. Can I distribute my app without vbrunXXX.dll?
   6. Why won't my setup program install commdlg.dll et. al.?
   7. Where do I install VBXs and DLLs?
   
   H. MISCELLANEOUS TIPS AND INFORMATION
   1. Multiple identifiers after the DIM statement can be confusing
   2. "Clean up" your project before final EXE compilation.
   3. Multiple END statements can be dangerous; or, The program that
       refused to terminate.
   4. What are the latest versions of the various files used by VB?
   
   I. VISUAL BASIC FOR APPLICATIONS (VBA)
   1. Any tips for VB/Win 3 programmers moving to VBA?
   2. Does VBA support VBXs?
   3. How do I access properties on my dialog boxes in VBA?
   4. How do I use database routines from Excel VBA?
   


A.   PREFACE

1.   About this document
   
   This document is a compilation of frequently asked questions and
   their answers about Visual Basic for Windows and Visual Basic for
   Applications which have been gathered from posts to the
   comp.lang.basic.visual.* newsgroups.  Although efforts have been
   made to find obvious errors, there is no guarantee that the
   information in this document is error-free. Neither the FAQ
   maintainer nor anyone else associated with this document assume
   ANY liability for the content or use of this document. If you find
   any errors, please report them to the address given below.
   
   This FAQ document is protected by international copyright
   regulations. Permission is granted to distribute it freely, both
   in electronic and written format, provided no charge is made.
   Also, do not make changes to this document without the consent of
   the maintainer. Usenet netiquette applies.

2.   Where to get the VB/Win FAQ [++]
   
   Most FAQs (including this one) are available at the anonymous ftp
   archive site "rtfm.mit.edu". All parts of the VB FAQ may be found
   here:
   
     ftp://rtfm.mit.edu/pub/usenet/comp.lang.basic.visual.misc/
   
   **Alternative FTP Sites**:
   The following are alternative sites to rtfm:
   
   North America: ftp.uu.net                     /usenet/news.answers
   Europe:        ftp.uni-paderborn.de           /pub/FAQ
                  ftp.Germany.EU.net             /pub/newsarchive/news.answers
                  grasp1.univ-lyon1.fr           /pub/faq
                  ftp.win.tue.nl                 /pub/usenet/news.answers
                  ftp.sunet.se                   /pub/usenet
   Asia:          nctuccca.edu.tw                /USENET/FAQ
                  hwarang.postech.ac.kr          /pub/usenet/news.answers
   
   (FYI:  "rtfm" stands for "Read The ******* Manual".  I kid you
   not!)
   [Andre van Meulebrouck (vanmeule@ils.nwu.edu)]
   
   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/comp.lang.basic.visual.misc/*
   
   in the BODY of the message.
   
   Alternative mailservers for those who have no ftp access
     ftpmail@decwrl.dec.com or ftpmail@cs.uow.edu.au
     bitftp@pucc.princeton.edu or ftpmail@lth.se
     bitftp@dearn or to bitftp@vm.gmd.de (Europe only)
     ftpmail@ftp.uni-stuttgart.de
     ftpmail@grasp.insa-lyon.fr or ftpmail@ieunet.ie
     bitftp@plearn.edu.pl or bitftp@plearn (Europe)
     ftpmail@doc.ic.ac.uk or ftpmail@sunsite.unc.edu
   [thanks to Jakob Faarvang (jakobf@apexsc.com)]
   
   For all mailservers:
   Use the "index" command to get a list of files available at the
   site.
   Use the "help" command to get more detailed instructions.
   (NOTE: commands are in BODY of mail message!)
   
   Note that a Web-browser like Netscape or Microsoft Internet
   Explorer easily can access an ftp site, view and download files.
   The ftp address on the top of this point (ftp://...) is formatted
   for these browsers; just copy and paste the text directly into the
   "URL" line.
   
   There is currently work going on to make these available in HTML
   format (for Web-browsers). This work is done by Peter Millard
   . Look at:
   
     http://www.buffnet.net/~millard/vblinks.htm
   
   or go directly to the copies of his HTML FAQ's (when finished!):
   
     http://www.buffnet.net/~millard/vbgenfaq.htm
     http://www.buffnet.net/~millard/vbdosfaq.htm
   

3.   Kudos & comments
   
   In this document, whenever a long line of code must be split into
   two or more lines of text in the code examples, a | symbol will
   precede each line which should be appended to the line above it.
   
   As the FAQ maintainer, I don't have time to explore all of the
   aspects of Visual Basic. Neither have I time or knowhow to
   personally answer direct technical questions thoroughly. 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!
   
   Jan Steinar Haugland (jansh@online.no), VB/Win FAQ maintainer
   
   Please note that my first language is not English. You can safely
   ignore all typos, but if you find an error that is so embarrassing
   you can't help pulling your hair and screaming loud, just send me
   a note and I'll correct it quietly. OK?
   
   This document is a collective effort! I would like to thank all
   contributers, and also all those who have given constructive
   feedback. This FAQ is now widely distributed in the net community.
   
   Special thanks to the following people who have made many and
   invaluable contributions to the VB/Win FAQ:  Kris Nosack (the
   previous maintainer), Peter Millard, Nic Gibson, Mr. "D" (the
   anonymous contributor), George Tatge (gat@csn.org), Andy Dingley
   (dingbat@codesmth.demon.co.uk), Ayn Shipley (ashipley@hookup.net)
   and those I may have forgotten (sorry).
   
   John McGuire (jmcguire@jax.jaxnet.com), a longtime VB user,
   recently went through the FAQ and found lots of things worth his
   comments. Many of his corrections and suggestions are implemented
   throughout. Thanks!
   
   Everybody: Your help is GREATLY appreciated!

B.   GENERAL VISUAL BASIC QUESTIONS
  

1.   Does VB/Win make standalone .EXE files?
   
   VB/Win produces .exe files, but they are not standalone. All
   VB/Win programs must be distributed with the VBRUNx00.DLL file
   (where x is the major version number). This DLL must accompany all
   VB/Win programs, but only one such file should reside on every
   system where VB programs are used.

2.   What is the current version of Visual Basic for Windows? [++]
   
   VB/Win is just between version 3.0 and 4.0 as of writing this. 4.0
   is about to be released around the same time as Windows 95. This
   will contain both a 16-bit and a 32-bit (for NT and Win95) version
   of the developing environment and the intergrated compiler.

3.   Where can I get updated VB and other Microsoft files?
   
   Microsoft Software Library (MSL) is accessible from the following
   services:
   
   - Compu$erve
   
     GO MSL
     Search for 
   
   - Microsoft Download Service (MSDL)
     Dial (206) 936-6735 to connect to MSDL
   
   - Internet (anonymous FTP)
     ftp ftp.microsoft.com
     Change to the \softlib\mslfiles directory
     (There are a LOT of files in this directory! It is not
     advisable to list all the files unless you have good time.
     See map below.)

4.   Help! I am lost on ftp.microsoft.com.
   
   You no longer have to be! The site have been reorganised, and
   you'll find the file DIRMAP.TXT in root (or whatever it's called
   on a 3.5 NT server). 

   NOTE: Directory and file names at ftp.microsoft.com are NOT case
   sensitive.
   
   Thanks to Richard Mason (richard@whitney.demon.co.uk) for the map
   he made for us before this long overdue reorganisation, and thanks
   for bringing this to my attention.

5.   Where can I get good up-to-date information about VB? [++]
   
   If you do any VB programming at all, you really should get the
   latest copy of the Microsoft Knowledge Base from one of the
   sources listed above!  The filename is VBKB.EXE or VBKB_FT.EXE for
   the version with full text searching. The Knowledge Base is a
   Windows help formatted document that is updated almost monthly.
   (Beware: The files are huge!)
   
   The EXE files on ftp.microsoft.com (and other places) are simple
   self-extracting files. They don't do any automatic updating of
   your system, just dump the file(s) inside them in the current
   directory on your disk, uncompressed and ready for use. Just
   replace the old files on your system with the new files (same
   name, usually).
   
   This FAQ (ahem) is a pretty good source as a digest of many of the
   VB issues that are discussed in the comp.lang.basic.visual.*
   newsgroups, but as such the information contained in this FAQ may
   not have been thoroughly tested or verified.
   
   For easier access to and use of this FAQ document, get the Windows
   Help file format FAQ doc by anonymous ftp to quasar.sba.dal.ca and
   look under /www/hlp. The .HLP version is made by Tim Roberts
   (TJR@SBACOOP.SBA.DAL.CA). This is HIGHLY RECOMMENDED.
   
   Dave McCarter puts out a nice Windows help formatted document
   called "Visual Basic Tips and Tricks". A good resource with
   information that isn't found in the Knowledge Base. It can be
   found by anonymous ftp to ftp.cica.indiana.edu
   /pub/pc/win3/programr/vbasic/ as VBTIPS??.ZIP, where '??' is the
   version number (yes, get the one with the highest number).
   
   [[ Mark Schoonover has started a monthly magazine called _VBWin
   Programmer's Magazine_ that is compiled around the Discussion of
   Microsoft Visual Basic and Related Issues mailing list. This
   magazine is available at the usual ftp sites like cica and at his
   BBS (619) 571-2846. Mark can be contacted at schoon@cts.com. It
   also has its own anonymous ftp site: ftp.cts.com in the
   /pub/schoon/VBWM.Issues directory. - ED: this appears to be down,
   alas. ]]
   
   Jakob Faarvang (jakobf@apexsc.com) maintains the useful CLBV
   Digest:
   
     http://www.apexsc.com/vb/clbv-digest/
   
   and
   
     ftp.apexsc.com:/pub/cgvb/clbv-digest/
   
   Address for him regarding CLBV Digest is clbv-digest-
   editor@apexsc.com
   
   There is presently an effort to put together a VB code library so
   that VB users can share their best - and trickiest - programming
   work. The code library project is being spear headed by Hein Ragas
   who has managed to get a directory on CICA for code snippets to be
   deposited. Stayed tuned to comp.lang.basic.visual.misc for more
   information.
   
   There's a VISBAS-L mailing list for Visual Basic (Thanks to David
   Liden (DL9U@Virginia.EDU) for tracking it down for me when it
   moved). You can subscribe to this mailing list by sending an email
   to
   
     listserv@listserv.tamu.edu
   
   Place the following text in the *body* of the message (no, not the
   subject line):
   
     SUB VISBAS-L Real Name
   
   Where Real Name is just that, *your full real name* not your email
   address. Note that the traffic on this list may overflow your
   mailbox if you have a limited mail buffer. Expect around 40-50
   messages every weekday, a bit less during weekends. Also, to
   unsubscribe, do as above but with "UNSUB" in the body of the
   message to the LISTSERV address, *not* to the VISBAS-L list
   address itself (Believe it or not, we usually receive 2-3
   sub/unsub mails evur  day on the list, and we're really fed up!)
   Also, this mail server was split and a new list called VBDATA-L
   was made for Vb database (Jet) related topics. Same procedure for
   registering (SUB VBDATA-L Real Name).
   
   The address for the MS ACCESS listserver is
   listserv@indycms.bitnet or listserv@indycms.iupui.edu The list
   name is ACCESS-L. To subscribe, you follow the same procedure as
   for the other lists.
   
   Sorry, I know no mailservers or other Internet resources dedicated
   to VBA specifically. Send me any information you may have, and
   I'll bring it on.
   
   There are several Usenet newsgroups dedicated to MS Windows
   programming and use. In fact, far too many to list here :-)
   
   NOTE: PLEASE don't post VB stuff to comp.lang.visual. This group
   has *nothing* to do with Visual Basic, and the academics
   discussing "real" visual programming there are very, very annoyed
   at what they call "quasi-visual" stuff and postings about those
   languages to their group.
   
   If you have a Compu$erve account, you will find a forum for Visual
   Basic there, including some support from Microsoft:
   
   MS BASIC Forum    (GO MSBASIC)
   
   Message Sections Available:             Libraries Available:
    1 Forum News/Info                       1 MS Info and Index
    2 Setup Wizard/Kit                      2 Setup Wizard/Kit
    3 Data Access Objects                   3 Data Access Objects
    4 The Data Control                      4 The Data Control
    5 Programming Issues                    5 Programming Issues
    6 ODBC Connectivity                     6 ODBC Connectivity
    7 SQL Queries                           7 SQL Queries
    8 ProEdition Controls                   8 ProEdition Controls
    9 Calling API's/DLL's                   9 Calling API's/DLL's
   10 Using OLE/DDE                        10 VBWIN-ODBC/Database
   11 MSCOMM control                       11 MSCOMM control
   12 MCI/MAPI controls                    12 MCI/MAPI controls
   13 DOS Visual Basic                     13 DOS Visual Basic
   14 DOS and Mac Basic                    14 DOS and Mac Basic
   15 Suggestions/Mktg.                    15 Suggestions/Mktg.
   16 CDK                                  16 CDK
   17 3rd Party Products                   17 3rd Party Products
   
   There are magazines dedicated to VB. The best known is Fawcett
   Technical Publications' _Visual Basic Programmer's Journal_
   (VSPJ). Phone 800-848-5523 (for US credit card orders) or 303-541-
   0610 (int'l and US other orders), Email 74003.224@compuserve.com
   to Shirley Modric for subscription info. Address is 280 Second
   Street, Suite 200, Los Altos, CA 94022-3603 USA.
   
   From Randy Coates (rcoates@telerama.lm.com):
   I currently subscribe to "Inside Visual BASIC for Windows" from
   the Cobb Group.  Although it is a helpful monthly paper (about 14
   pages per publication), I find it to be overpriced when compared
   to VB Programmers Journal.  Here is the information anyway:
   Domestic $59/yr ($7.00 each); Outside US $79/yr ($8.50 each)
   Phone: Toll Free: 800-223-8720),  Local: 502-491-1900, Customer
   Relations Fax: 502-491-8050, Editorial Department Fax: 502-491-
   4200. Address: _Inside Visual BASIC for Windows_, 9420 Bunsen
   Parkway, Suite 300, Louisville, KY  40220.
   
   (Note: for completeness other VB magazines should be listed, and I
   would like to receive info on those!)
   

6.   WWW pages for VB! [**]
   
   Carl 'n Gary's Visual Basic HomePage is a good place to start:
   
      http://www.apexsc.com/vb/
   
   This page has hotlinks to lots of goodies, including the FAQs,
   clbv.* archives (with search tool), etc. Send any e-mail inquiries
   (about the page!) to:
   
      vb-admin@apexsc.com
   
   [Gary Wisniewski (gary@apexsc.com)]

7.   Are there any examples of commercial applications built using
   Visual Basic?
   
   Profit by Microsoft was written mostly in Visual Basic. In fact,
   Profit was one of three programs selected as PC Magazine's
   Editor's Choice among Windows small business accounting packages.
   Most of the current version of Quicken was written in VB2. The
   viewer/launcher/installer in the oh-so-popular Way Cool [Topic]
   for Windows series of CD-ROMs was written in VB3.
   
   Microsoft uses VB extensively for smaller utilities. 3 of the
   small apps in the Windows and Windows for Workgroups Resource
   Toolkits are written in VB. Also, if you have the Microsoft
   Bookshelf CD-ROM, you will notice that the MVOPTION.EXE program,
   which is an "options" program for MS Viewer, is created in VB.
   
   Note: The existence of VBX files in a package doesn't ecessarily
   mean that it was written in VB. The most popular C++ compilers
   also support VBXes.

8.   Limits of VB?
   
   Are you kidding? VB have *no* limitations... Uh, yeah ;-)
   
   For starters:
   
   * It's not a true compiler, hence it's slow for non-interface
   stuff (it's of
     course slow for interface stuff as well, but that's *Windows*
   not VB)
   
   * It's not really object-oriented (Try looking for the parent of
   ie. a line
     control, and you'll wonder why it has no hWnd  - SpyWorks is an
   add-on you
     may need if this is annoying)
   
   * A statement must be on a single line! (Note: Fixed in VB4!!!!)
   
   * No arrays of constants.
   
   * Your Complaint Here!
   
   An enormous amount of contributers to this topic! Can you guess
   why?
   [Entry suggested by Andre van Meulebrouck (vanmeule@netcom.com)]


C.   COMMON VISUAL BASIC PROGRAMMING QUESTIONS
  

1.   What's the difference between MODAL and MODELESS forms? [++]
   
   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 in that application until it is dismissed. When
   showing a modal form, the controls outside this modal form will
   not take user interaction until the form is closed. The internal
   MsgBox and InputBox forms are examples of modal forms. To show a
   form modally, use the syntax:
   
     MyForm.SHOW 1
   
   MODELESS forms are those which are shown but do not require
   immediate user input. MDI child forms are always modeless. To show
   a form modeless, use the syntax:
   
     MyForm.SHOW
   
   (Thanks to John M. Calvert (calvertj@magi.com) for correcting a
   slightly embarrassing mistake in previous versions of this topic)

2.   When/Why should I use Option Explicit?
   
   Option Explicit forces you to declare all variables before using
   them. 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, some suggest using 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
   variant (VB 3.0) or single precision (VB 1.0 and 2.0). (Integers
   take up less memory).
   
   The OPTION EXPLICIT statement causes VB to 'disable' its 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 bugs caused by a misspelled variable.
   The option works module-wide, so you can have some modules with
   and some without this option in your project.

3.   Why does everybody say I should save in TEXT not BINARY?
   
   Actually, saving in binary mode is a bit faster, so why do we
   recommend you to save in text?
   
   If you save the source and the project as text, it becomes ASCII
   (or really, ANSI) code that you can edit with any text editor or
   (if you are careful when you save) word processor. If you save in
   binary, only the VB development environment, current or later
   versions, will understand the code. The Setup Wizard can not scan
   binary projects. Also, source documenters and other programming
   tools usually require text mode. If you use text, you can use a
   simple text editor (ie. notepad) to cut and paste code from other
   source/form modules into your current project. Some 'tricks' (like
   making an array of 1 control into a single non-array control
   again) is easily done with an editor but not that easy in the
   environment. If you want to print your project to paper the
   file|print option in the VB environment is often not good enough;
   you may want to import the text files into your word processor.
   And, finally, if something goes wrong (only one byte is changed!)
   you may be out of luck in binary mode. In text mode you will more
   easily be able to fix it.

4.   Is the Variant type slower than using other variable types?
   
   Generally, yes, if we are talking numeric variable types. The
   Variant type also increases memory overhead. To test the speed
   difference, try the following piece of code in something like a
   button_click event and keep the debug window on the screen:
   
     Dim Va As Variant
     Dim In As Integer
     T1! = Timer
     For i% = 1 To 32766
       Va = i%
     Next i%
     T2! = Timer
     Debug.Print "With variant:  "; Format$((T2! - T1!), "0.0000")
     T1! = Timer
     For i% = 1 To 32766
       In = i%
     Next i%
     T2! = Timer
     Debug.Print "With integer:  "; Format$((T2! - T1!),"0.0000")
   
   This test shows (on our test system) that integers are ~60%
   faster! However, for strings there where no real difference, or in
   some instances, variants were faster than strings for routines
   with heavy conversion usage. For the best result in your
   application, test your routines directly.

5.   How do I make a text box not beep but do something else when I
   hit the Enter key?
   
   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
         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. Often they will
   want to jump to the next control, like the Tab key does. To have
   the Enter key emulate the Tab key action, you will need to add the
   line 'SendKeys "{tab}"' above 'KeyAscii=0' in the example above
   (Yes, I thought KeyAscii=9 works but it doesn't! Tab is obviously
   handled by Windows on a lower level).
   
   By the way, you'll also find this in the Microsoft VB Knowledge
   Base (see KB Q78305 and Q85562).
   
   Note: If MultiLine=True you will *not* want to disable the normal
   behaviour of the Enter key.

6.   How do I implement an incremental search in list/dir/combo/file
   boxes?
   
   This is your lucky day. Dan Champagne (Dan_Champagne@dell.com)
   made some VB code (no DLLs are necessary!) which easily provides
   this feature for your applications:
   
     ' Code by Dan Champagne
     ' 4/18/94
     
     ' This code can be used to do an incremental search in either a
     ' list box, dir, combo, or a file box. The following code is set
     ' for a file box called FILE1. To make it work with a list box, or
     ' a file box with a different name, change all occurences of FILE1
     ' with whatever you or VB has named your list, combo, dir, or file box.
     ' There are two places where you will need to change these. They are
     ' on the last couple of lines in the KeyPress code.
     ' Also, thanks to John Tarr for helping debug the code.
     
     'In a .BAS file, add the following:
     'searchme$ is a global vaiable that will keep track of what the
     'user has typed so far.
     Global searchme$
     
     'The following needs to be on one line.
     Declare Function SendMessageBystring& Lib "User" ALIAS
     |"SendMessage" (ByVal hWnd%, ByVal wMsg%, ByVal
     |wParam%, ByVal lParam$)
     
     Global Const WM_USER = &H400

Section 1 of 4 - Prev - Next
All sections - 1 - 2 - 3 - 4

Back to category visual-basic-faq - Use Smart Search
Home - Smart Search - About the project - Feedback

© allanswers.org | Terms of use

LiveInternet