Dec 222017
 
Visual Basic Knowledge Base #2.
File VBKBASE2.ZIP from The Programmer’s Corner in
Category BASIC Language
Visual Basic Knowledge Base #2.
File Name File Size Zip Size Zip Type
TPCREAD.ME 199 165 deflated
VBKBASE2.TXT 220619 53295 deflated

Download File VBKBASE2.ZIP Here

Contents of the VBKBASE2.TXT file


Title: Wrong Default Path After Drive Error, VB Open/Add File Dialog
Document Number: Q72878 Publ Date: 25-JUN-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
When you choose the Open Project or Add File option from the File menu
in the VB.EXE environment, and you get an error accessing a disk
drive, Visual Basic incorrectly stays logged onto the failed drive
path (even though the previous path is displayed), unless you
explicitly change the drive. (This behavior differs from the Open
command from the File menu in standard Windows applications, such as
Microsoft Word for Windows and Microsoft Excel for Windows.)
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. Microsoft is researching
this problem and will post new information here as it becomes
available.
To work around this problem, just change to a valid drive by typing a
path preceded by a valid drive letter, or by selecting a valid drive
letter with the mouse.
More Information:
To duplicate this problem, follow these steps:
1. Start Visual Basic (such as from the C:\VB\ subdirectory for the
following example).
2. From the File menu, choose Open Project or Add File. (The Open
Project or Add File dialog box lets you search for and select the
file you want.)
3. Make sure drive A is empty and open.
4. Select [-a-| from the dialog box. A message box will correctly
appear with the error message "Path Not Found:'' ". (What appears
to be one double quotation mark is really two single quotation
marks with nothing between them.)
5. Choose the OK button. Note that the current path, such as C:\VB
(displayed above the Directories box), is correctly shown to be the
same as before drive A was selected. The Files and Directories
boxes also correctly show the same files as before drive A was
selected. (So far, this behavior is the same as for the files
dialog box in standard Windows applications.)
6. Erase the information in the File Name field, and type the
following:
*.*
7. Choose the OK button.
8. The problem is that Visual Basic now incorrectly gives you the
"Path Not Found:'' " error message, which demonstrates that the
actual current drive fails to match the displayed path (C:\VB), and
Visual Basic is incorrectly attempting to access drive A again.
This behavior differs from standard Windows applications, such as
Microsoft Word for Windows and Excel for Windows, which don't give
an error at this point, and instead correctly show all (*.*) files
in the path (C:\VB) displayed in the dialog box.
To work around this problem, just change to a valid drive by typing
a path preceded by a valid drive letter, such as C:\VB\*.*, or by
selecting a valid drive letter, such as [-c-| with the mouse.
Title: Settings Box Is Hidden When Properties Bar at Bottom of Screen
Document Number: Q72881 Publ Date: 25-JUN-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
When the Properties bar is positioned at the bottom of the screen and
an enumerated property, such as FontName, is selected from the
Settings box, the FontName list is still displayed beneath the
Properties bar, instead of above the Properties bar, making the
FontName list essentially invisible. Because of this behavior,
Microsoft recommends leaving the Properties bar at the top of the
screen.
Note: The Properties bar's entry field is not a combo box, and does
not react as a combo box.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
When you open a combo box and the space below is insufficient to
display the drop-down list, the list will be displayed above the combo
box window. This is exactly how the combo box "Properties list box"
displays when the Properties bar is moved to the bottom of the screen.
Although the Settings box resembles a combo box, the Settings box is
actually an edit box and a push button. This window is not a combo box
because the push button can take on several functions. In some cases
the Settings box is disabled, and in some cases it invokes a pop-up
dialog box (for example, when you select the Picture property of the
Picture control). In other cases, such as for the FontName property,
the Settings box displays a Windows list box just under the Properties
bar. The location of the list box is determined by Visual Basic and
will always be displayed below the Properties bar.
Microsoft recommends leaving the Properties bar at the top of the
screen.
Reference:
Please refer to pages 38-39 of the "Microsoft Visual Basic:
Programmer's Guide" for version 1.0 for definitions of Properties bar,
Properties list box, and Settings box.
Title: Why VB Sub Might Stay in Proc: List Even After Code Deleted
Document Number: Q73270 Publ Date: 25-JUN-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
In a Visual Basic code window, if you want to delete the code for a
Sub...End Sub procedure (or Function...End Function procedure), you
must also delete the two or more blank lines (if any) following that
procedure, or else that procedure will still exist (in a blank code
window and in the Proc: box).
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
version 1.0 programming system for Windows. We are researching this
problem and will post new information here as it becomes available.
To work around this problem, make sure to delete all blank lines in
the code window for the procedure that you want to delete.
More Information:
Steps to Reproduce Problem
--------------------------
1. Start Visual Basic (or select New Project from Visual Basic's File
menu if you are already in Visual Basic).
2. Double-click Form1, or press F7, to display the form's Code window.
3. Choose (general) from the Object: box, and enter the statement
Sub Sub1 in the (general) (declarations) code window, and press the
ENTER key. This causes Visual Basic to display the following Sub
procedure:
Sub Sub1()
End Sub
4. Press CTRL+END, or click to the blank line after the End Sub
statement.
5. Press the ENTER key to add a few blank lines after the End Sub
statement.
6. Using the mouse, select (highlight) from the Sub Sub1() statement
to the End Sub statement (but to duplicate the problem, don't
highlight the blank lines after the End Sub statement). From the
Edit menu, choose Delete, or press the DEL key, to delete the
selected text.
7. Now the Proc: box still indicates that Sub1 exists as a procedure,
even though you just tried to delete it.
This problem is caused by the blank lines that were added after the
End Sub statement. To work around the problem, highlight and delete
the blank lines in the Sub1 code window, and the Sub1 procedure will
be properly deleted.
Additional reference words: 1.00
Title: Can't Get Help Within Any VB Dialog Box After an Error
Document Number: Q73119 Publ Date: 25-JUN-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: MS-DOS

Summary:
If you are in any Visual Basic dialog box and an error occurs, after
you dismiss the error message, pressing F1 to get help for the dialog
box will result in getting help on the previous error message, not
help on the dialog box.
Microsoft has confirmed this problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
More Information:
The following steps reproduce the error:
1. From the File menu, choose Save Project.
2. Enter an invalid filename for saving the project.
3. An error message will pop up telling you that the filename is
incorrect.
4. Press ENTER or double-click the OK button to dismiss the error
message.
5. Press the F1 key to get help on the Save Project dialog box.
6. The help message for the error will pop up, instead of help for the
dialog box.
This behavior is incorrect. The above steps should give you help for
the Save Project dialog box.
To work around the problem and get correct help on this dialog box,
dismiss the incorrect error message by double-clicking the control
button, and click CANCEL to get rid of the Save Project dialog box.
Now, choose Save Project from the File menu and press F1; the correct
help should display.
To get help on the error message, press F1 while the error message is
displayed.
Title: "Method Not Applicable..." with IsHidden Method in VB
Document Number: Q73154 Publ Date: 25-JUN-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
"IsHidden" was a method implemented in prerelease versions of Visual
Basic, but IsHidden was removed in the released version (because it
was no longer needed). However, using IsHidden as the name for a
variable, Sub, Function, or object can still give the following error
at run time:
Method not applicable with this Object
To work around this problem, avoid using the name IsHidden.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
The following example demonstrates the problem:
1. Within any event procedure, try the following:
Sub Form_Click()
print ishidden
End Sub
2. This gives a syntax error asking you to add a "(" to the method,
so continue by adding "()":
Sub Form_Click()
print ishidden()
End Sub
3. This results in the following format after pressing ENTER after
ishidden():
Sub Form_Click()
Print IsHidden()
Sub End
This is the format for a predefined method called IsHidden().
After following the steps above, you will receive a run-time error
"Method not applicable with this Object." This error results because
this particular method was not completely unimplemented from the beta
version.
Microsoft will consider completely removing this behavior of the
IsHidden name in a future version of Visual Basic.
Title: Make EXE with 40-Byte Title Displays Only 39 in Task List
Document Number: Q73155 Publ Date: 25-JUN-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
The following steps demonstrate a problem with Microsoft Windows 3.0;
the problem is not caused by Microsoft Visual Basic version 1.0:
1. Start Visual Basic.
2. From Visual Basic's File Menu, choose the Make EXE File command.
3. A Make EXE File dialog box will display. Enter a 40-character
filename in the File Name box.
4. Double-click the OK command button to exit the dialog box.
5. Minimize Visual Basic, go to the Windows Program Manager menu, and
choose File.
6. From the File menu, choose the Run option; the Run dialog box will
display.
7. Now enter that 40-character .EXE filename or path to the .EXE
filename in the Command Line box, and double-click OK when done.
8. The .EXE file will run correctly, but if you press CTRL+ESC to
bring up the Task List box, you will see that your .EXE filename
has been truncated to 39 characters (it no longer is 40
characters).
Microsoft has confirmed this problem in the Microsoft Windows version
3.0 operating system (buglist3.00). We are researching this problem
and will post new information here as it becomes available.
Additional reference words: 3.00
Title: Removing Disk During VB Setup Terminates SETUP, Missing Files
Document Number: Q73157 Publ Date: 25-JUN-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
While running SETUP.EXE for Visual Basic, you may fail to copy all
files (or experience other problems) if you try to remove the disk
while the SETUP.EXE program is in progress.
Microsoft has confirmed this problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
To work around this problem, wait until SETUP indicates that 100
percent of the files are copied before removing the Visual Basic
floppy disk.
More Information:
Below is an example of one specific problem:
When running SETUP.EXE on Disk 1 of Visual Basic (using 1.2 MB 5.25-
inch disks), you can choose the option to install Visual Basic only.
SETUP's bar graph will start by displaying 4 percent done, and while
the large file C:\VB\VB.EXE is being copied, the disk drive light may
go off and you might assume that Visual Basic is finished running
SETUP. At this point you might (mistakenly) remove Disk 1. Then a
message tells you that SETUP is complete, and you can exit SETUP.
You have now installed VB.EXE, but you did not install some of the
other important files, such as VBRUN100.DLL, which is needed to run
your compiled applications under Windows version 3.0.
If you want to install Visual Basic by selecting Visual Basic only,
then you need to let Disk 1 complete its processing by waiting until
the bar displays 100 percent. If you let Disk 1 run to completion,
then the installed directory C:\VB should correctly contain the
following files:
VB.EXE
VB.HLP
VBRUN100.DLL
README.TXT
PACKING.LST
SETUP.EXE
DECOMP.DLL
CONSTANT.TXT
Additional reference words: 1.00 3.00
Title: Memory Limits in Visual Basic for Windows
Document Number: Q72879 Publ Date: 26-JUN-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
The following memory limitations apply to Microsoft Visual Basic
programming system version 1.0 for Windows.
Note: This information only applies when running the retail version of
Microsoft Windows version 3.0. Different memory limitations may apply
when running Visual Basic under the debug version of Windows provided
with the Microsoft Windows Software Development Kit (SDK).
More Information:
Each Function or Sub procedure can have up to 64K of pseudo code
(pcode).
Each Form, Module, and Global Module gets its own data segment (up to
64K in size) for the allocation of all static data, strings, and
simple variables (declared in the General section and Sub and Function
procedures).
Each array of any data type gets its own data segment, up to 64K in
size. Arrays larger than 64K cause a "subscript out of range" error.
Huge arrays (arrays larger than 64K) are not directly supported in
Visual Basic, but you can support huge arrays through the use of a
Windows dynamic-link library (DLL). A separate article discussing
support for huge arrays can be found by querying on the following
words:
huge and array and DLL
The properties for all controls on a form and the properties of
the form itself go into a single data segment limited to 64K bytes,
except the following:
The List() property of a List Box
The List() property of a Combo Box
The Text property of a Text Box
The List() property gets its own data segment, limited to 64K bytes,
for each List Box and Combo Box. The Text property of a Text Box has a
default size limit of 32K, which can be increased to 64K with a call
to a Windows API function. For more information on how to increase the
amount of text (from 32K to 64K) that can be entered into a Text Box,
query on the following words:
windows and api and sendmessage and textlimit
Other memory limits relating to the properties of Controls and Forms
include:
1. Each item in the List() property can be up to 1K in size, any item
over this limit is truncated.
2. The Caption property of a control can be up to 1K in size, any
Caption over this limit is truncated.
3. The Tag property of a control can be up to 32K in size, any Tag
over 32K causes an "out of memory" error.
There is one name-and-symbol table up to 32K in size per Form, Module,
or Global Module. A name-and-symbol table contains the actual text of
Sub function and Sub procedure names, variable names, line numbers,
line labels, and an additional 4 bytes overhead for each of these
names and symbols.
If the 32K size limit is exceeded for a name-and-symbol table, an "out
of memory" error will occur. To solve this, break up the Form or
Module into multiple Forms or Modules. Note, this cannot be done with
the Global Module. Only one Global Module is allowed; if you exhaust
the Global Module's name-and-symbol table, there is no workaround,
other than to use shorter variable names.
The stack is 16K in size, with just one stack per application. The 16K
stack size cannot be changed. Note that an "out of stack space" error
can easily occur when your program uses uncontrolled recursion.
If you run Visual Basic on the debug version of Microsoft
Windows provided with the Microsoft Windows SDK, all properties
(including List() and Text properties) go into a single segment, up to
64K in size per Form or Module. Other memory management limits may
also differ under the debug version of Microsoft Windows. The debug
version of Windows is created by copying a set of dynamic-link library
(DLL) files from the Windows SDK into your \WINDOWS\SYSTEM
subdirectory. These special DLLs perform additional error checking,
including a check for stack overflow.
Title: Code Causing Run-Time Error Can Be Hidden If in Split Window
Document Number: Q73156 Publ Date: 26-JUN-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Under certain circumstances, using a split window in the Visual Basic
environment can hide the code, which results in a run-time error.
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
To work around the problem, use step 8 shown below.
More Information:
The following example demonstrates a problem using split screens
in Microsoft Visual Basic programming system version 1.0 for Windows:
1. Start Visual Basic, and from the File menu choose New Project.
2. Using the mouse, double-click on Form1; the Code window will
display.
3. From the Code window, press the Maximize button so the entire
screen displays Form1's Code window.
4. Select the split window bar, and click and drag the split
window down to about two inches from the bottom of the screen.
5. The Sub Form_Click() should be displayed in the lower half of the
split window. Enter the following code:
Sub Form_Click()
Print 1/0 'enter this line
End Sub
6. Now run the sample code by choosing Start from the Run menu or
by pressing the F5 function key.
7. After choosing Start from the Run Menu, click the Form1 window;
a "Division by zero" error will display. The error occurs because
of the "Print 1/0" statement coded above, but you cannot see the
line of code where the error occurred.
8. If you click on the Maximize button for FORM1.FRM, you will see that
the error occurs on the Print 1/0 statement. Use this method to work
around the problem.
Title: VB Replace Command Using Verify Can Incorrectly Repeat Replace
Document Number: Q73271 Publ Date: 26-JUN-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
This article discusses a problem with the Verify option of the Code
menu's Replace command in the Microsoft Visual Basic version 1.0
editor. If the search string is a subset of the replacement string,
and if the Visual Basic syntax parser automatically inserts a space in
the replacement string, then the Replace command with Verify
incorrectly repeats the Replace on text that was part of the
replacement string itself.
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
version 1.0 programming system for Windows. Microsoft is researching
this problem and will post new information here as it becomes
available.
To work around the problem, you can manually put space that would be
inserted by the syntax parser in the replacement string (as described
below). The problem does not occur with the Replace All option.
More Information:
Steps to Reproduce Problem
--------------------------
1. Start Visual Basic (or select New Project from Visual Basic's File
menu).
2. From the Project1 window, double-click GLOBAL.BAS. This displays the
Global module window. (Note that this Replace problem can occur in
any code window.)
3. In the Global module window, enter the following code:
Global A(2)
[Or enter Dim A(2) in the code window of any non-Global module.|
4. Now choose the Replace command from the Code menu.
5. The Replace window contains two text boxes named "Find What:" and
"Replace With:". In the Find What text box, enter a ")" and then
tab to the Replace With text box and enter ",2)".
6. Choose the Verify command button.
7. The Verify window prompts you with "Replace Selected Text" [Yes| or
[No|. If you choose the Yes command button, the replacement
occurs correctly. The problem doesn't occur until you choose the
Yes command button for a second time (and third, and so on), which
will incorrectly add another string of text at the same location.
The problem is caused by the space that the Visual Basic parser
automatically inserts after the comma. This causes Visual Basic to
effectively start the next search one character too early, causing the
search to find the ")" that was just inserted. The problem can be
avoided by changing the Replace string to ", 2)" (with a space after
the comma).
You can also avoid the problem by choosing the "Replace All" command
button instead of the Verify command button (mentioned in step 6
above). This correctly does the Replace and displays the "Search
complete" window.
You can also avoid the problem by selecting the No command button the
second time the Verify window is displayed (in step 7) (and then
choose the OK command button when the "Search complete" window
displays).
Title: Can't Use Multiple & (for Access Keys) in a VB Menu Control
Document Number: Q73372 Publ Date: 26-JUN-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
When creating a menu control that has multiple & (ampersand)
characters to mark the access keys in the caption (for example,
&a&b&c&d), the menu will appear with an underline under the character
after the last &. However, the access key will respond to the
character following the first &. This is not a problem with Visual
Basic, but rather with the Windows operating environment.
This information applies to the Microsoft Visual Basic programming
system version 1.0 for Windows.
To work around this problem, do not put multiple & characters in the
menu caption; just use one & character per caption.
More Information:
Steps to Reproduce Problem
--------------------------
1. From the File menu, choose New Project (ALT+F+N).
2. From the Window menu, choose Menu Design Window (ALT+W+M).
3. Enter "&A&B&C&D" (without the quotation marks) for the Caption.
4. Enter "ABCD" (without the quotation marks) for the CtlName.
5. Choose the Done button.
6. Click on the menu item ABCD on Form1.
7. Enter the statement Print "ABCD" in the click event for the menu
item ABCD as follows:
Sub ABCD_Click ()
Print "ABCD"
End Sub
8. Run the program.
When the program is run, the D in the menu caption will be underlined,
but the menu responds to ALT+A, not ALT+D.
Title: UAE Placing More than 64K in VB List Box or Combo Box
Document Number: Q73374 Publ Date: 26-JUN-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Attempting to add more than 64K of data into a Visual Basic list box
or combo box will result in a Windows UAE (unrecoverable application
error).
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. Microsoft is researching
this problem and will post new information here as it becomes
available.
More Information:
Each item of a list box or combo box can contain a string up to 1K in
length; however, if the total of all items exceeds 64K, a UAE will be
generated. The .List() property for list boxes and combo boxes is
given its own segment up to 64K in size. If an attempt to exceed this
limit is made, an "Out of memory" or "Out of string space" error
message should result, but instead a UAE occurs and the program
terminates.
Steps to Reproduce Problem
--------------------------
1. Create a New Project.
2. Draw a list box on Form1.
3. Add the following code to Form1's Click() event procedure:
Sub Form_Click()
Do
List1.Additem String$(1024, "X")
I = I + 1
Debug.Print I
Loop
End Sub
When the UAE occurs, note that the value of the variable "I" displayed
in the Immediate window will be 63. The UAE occurred when adding the
64th item, which caused the total size of the data in the list box to
exceed 64K. The actual limit is slightly under 64K due to a small
amount of overhead to manage the .List() property because it is a
property array.
Title: VB Cls Method on Thin and Wide Picture Control May Give UAE
Document Number: Q73375 Publ Date: 26-JUN-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: MS-DOS

Summary:
Performing a Cls method on a picture control can generate a UAE
(unrecoverable application error) message under the following
conditions:
1. AutoRedraw = TRUE for the picture control.
2. The .Width property for the picture control is very large
(approximately 20 times the width of the screen if running Windows
with a 256-color video driver, or approximately 40 times the width of
the screen if running Windows with a 16-color video driver.)
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. Microsoft is researching
this problem and will post new information here as it becomes
available.
More Information:
Steps to Reproduce Problem
--------------------------
1. Start Windows using a 256-color driver and run Visual Basic
(VB.EXE).
2. Create a New Project and place a picture control on the form.
3. Add the following code to the Form_Click procedure:
Sub Form_Click()
Form1.ScaleMode = 3 ' PIXEL's
Picture1.AutoRedraw = -1
Picture1.Height = 34 ' 64 for 16 color video driver
For i% = 380 To 390
Picture1.Width = Picture1.Height * i%
Picture1.Cls
Debug.Print Picture1.Width
Next i%
End Sub
4. Press F5 to run the program. You will now receive a Windows
UAE message.
Note the value of Picture1.Width at the time of the UAE. It
should be approximately 20 times the width of your current screen
resolution.
Title: Clicking on Toolbox/Color Palette Menu Doesn't Leave Menu Open
Document Number: Q73418 Publ Date: 1-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
When you single click in the System menu (the Control menu in the
upper left corner) of the Toolbox or the Color Palette in the Visual
Basic environment, the menu flashes on the screen but does not stay
visible like normal Windows System menus. This is by design.
To keep the Toolbox or Color Palette system menu pulled down, you must
hold down the mouse button.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
On a normal Windows System menu, a single mouse click pulls down the
menu and keeps the menu down without having to hold down the mouse
button. Even though the System menus of the Toolbox and Color Palette
may look like normal System menus, they do not act like them, and are
not "normal" Windows System menus. They were not designed to stay open
with a single mouse click; therefore, the menu will flash briefly on
the screen on a single mouse click and then disappear, unless you keep
the mouse button held down.
Title: VB Repaint Problem at Design Time with > 50 Controls on Form
Document Number: Q73505 Publ Date: 1-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
If a combination of more than 50 text boxes and text labels are placed
on a form, the form may be repainted incorrectly. The usual result is
that the grid points are lost, the title bar and border are missing,
and portions of the controls are missing. This is a problem that
occurs at design time in the Visual Basic development environment. The
problem does not apply to a program that is run in the Visual Basic
environment or run as a .EXE program.
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
This problem has only been observed with text boxes and labels. Other
controls on the form (command buttons, picture boxes, and so on)
repaint correctly.
More Information:
The following steps may reproduce the error on some machine
configurations:
1. Create a new form and place 50 text boxes and/or labels on the
form.
2. Double-click on one of the controls to bring up its code window.
3. Make sure the code window covers most of the form, then close the
code window by double-clicking on its control box.
4. The grid points, title bar, and border may be missing on the
repainted form.
To repaint the form correctly, position the mouse pointer above where
the title bar should be, hold down the left button, and move the form
window. This will bring back the title bar and border. To get the grid
points back, choose Grid Settings from the Edit menu, make sure the
Show Grid option is enabled, then choose OK. Your form should now be
repainted correctly.
Title: Large Grid Settings Can Make Moving Controls Difficult
Document Number: Q73506 Publ Date: 1-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
The Align to Grid feature in the Edit menu in the Microsoft Visual
Basic environment can sometimes prevent you from moving a text box
control.
Microsoft has confirmed this problem in Microsoft Visual Basic
programming system version 1.0 for Windows. Microsoft is researching
this problem and will post new information here as it becomes
available.
More Information:
Steps to Reproduce Problem
--------------------------
1. From the Edit menu, choose Grid Settings. Set the grid settings as
follows:
Width: 1485 Height: 1485 Show Grid ON Align to Grid ON
2. Add a text box control and move it so that the top of the text box
is even with the second row of the grid (the first row is even with
the top of the form).
3. Select the top half of the text box and try to move it up to the
row above. In most instances, you will not be able to move the text
box to the desired location.
Title: Overlapping Controls Not Supported in Visual Basic
Document Number: Q73651 Publ Date: 2-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Overlapping Visual Basic controls may not respond as expected to mouse
events. For example, the bottom control will receive the mouse event
even when it appears that you have selected the top control. The use
of overlapping Controls is not supported in Microsoft Visual Basic
version 1.0.
This information applies to the Microsoft Visual Basic programming
system version 1.0 for Windows.
More Information:
Although the Visual Basic design editor allows you to overlap
controls, when you run the application the region of the controls that
overlap may not function as you would expect.
For example, if two Command buttons, Command1 and Command2, overlap so
that Command1 is partially on top of Command2, when you select
Command1 within the region of overlap you would expect a Click event
to be issued for Command1. However, the Click event may occur on
Command2 even though it is underneath Command1 in the overlapping region.
Title: UAE Exiting Windows when VB Form1 Unload Event Unloads Form2
Document Number: Q73656 Publ Date: 2-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
A Windows "Unrecoverable Application Error" (UAE) message will occur
if you terminate Microsoft Windows 3.0 under the following conditions:
1. A Visual Basic version 1.0 application is resident (running in the
background or foreground).
2. The Visual Basic application contains multiple forms.
3. The Unload event procedure of one form unloads another form.
4. The Visual Basic application is compiled and run as an .EXE program.
This problem does not occur when you run the program from the Visual
Basic development environment.
Microsoft has confirmed this problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
More Information:
Steps to Reproduce Problem
--------------------------
1. Start Visual Basic, and Form1 will automatically be created by
default. (If you already have a project loaded in the Visual Basic
environment, you can select New Project from the File menu
[ALT+F, N|.)
2. From the File menu, choose New Form. This will create Form2.
3. Add the following code to Form1's Load event procedure:
Sub Form_Load ()
Form2.Show
End Sub
4. Add the following code to Form1's Unload event procedure:
Sub Form_Unload (Cancel As Integer)
Unload Form2
End Sub
5. From the File menu, choose Make EXE File (ALT+F, K) to create an
.EXE file.
6. From the Windows Program Manager's File menu, choose the Run
option, and run the Visual Basic .EXE program that you just
created.
7. Terminate Windows (ALT+F, X from the Windows Program Manager). The
Windows UAE message occurs. The computer may hang after you click on
the OK button of the UAE dialog box.
The UAE message incorrectly occurs because of the attempt to unload
Form2 from Form1's Unload event procedure. This is a known problem
when attempting to use the Unload method for one form from within the
Unload event procedure of another form.
To work around this problem, remove the Unload method from the Unload
event procedure or use the End statement in the Unload event procedure
instead.
Title: Determining Number of Lines in VB Text Box; SendMessage API
Document Number: Q72719 Publ Date: 8-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
To determine the number of lines of text within a text box control,
call the Windows API function SendMessage with EM_GETLINECOUNT(&H40A)
as the wMsg argument.
Calling SendMessage with the following parameters will return the
amount of lines of text within a text box:
hWd% - Handle to the text box.
wMsg% - EM_GETLINECOUNT(&H40A)
wParam% - 0
lParam% - 0
This information applies to Microsoft Visual Basic programming
system version 1.0 for Windows.
More information:
As an example to determine the amount of lines within a text box,
perform the following:
1. Create a form with a text box and a command button. Change the
MultiLine property of the text box to TRUE.
2. Declare the API SendMessage function in the global-declarations
section of your code window. (the Declare statement must be
on just one line):
Declare Function SendMessage% Lib "user" (ByVal hWd%,
ByVal wMsg%,
ByVal wParam%,
ByVal lParam&)
3. You will need to declare another API routine to get the handle of
the text box. Declare this also in your global-declarations section
of your code window. The returned value will become the hWd%
argument to the SendMessage function.
Declare Function GetFocus% Lib "user" ()
4. Within the click event of your button, add the following code:
Sub Command1_Click ()
Const EM_GETLINECOUNT = &H40A 'defined within SDK WINDOWS.H
' command button has focus, give focus to text box.
Text1.SetFocus
' get the handle of the text box.
hWd% = GetFocus()
' print the amount of lines to the immediate window.
Debug.Print SendMessage(hWd%, EM_GETLINECOUNT, 0, 0)
End Sub
5. Run the program. Add several lines of text to the text box. Click
the command button to see the number of lines printed out to the
immediate window.
References:
"Programming Windows: the Microsoft Guide to Writing Applications for
Windows 3," by Charles Petzold (published by Microsoft Press, 1990)
"Peter Norton's Windows 3.0 Power Programming Techniques," by Peter
Norton and Paul Yao (published by Bantam Computer Books, 1990)
"Microsoft Windows 3.0 Software Development Kit: Reference Volume 1"
The WINSDK.HLP file shipped with Microsoft Windows 3.0 Software
Development Kit
Title: How to Make a VB Text Box Control with a Password (*) Style
Document Number: Q71457 Publ Date: 16-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
In the password style for a control, all characters display as an
asterisk (*) as they are typed into the control. Microsoft Visual
Basic does not have any intrinsic function for creating an edit
control with the password style. You can add the password style to a
Visual Basic text box control by using several Windows API function
calls.
This information applies to Microsoft Visual Basic Programming System
version 1.0 for Windows.
More Information:
Adding the password style to a text box control can be performed by
calling several Windows API function calls. These functions are
GetFocus, GetWindowLong, SetWindowLong, and SendMessage.
The function GetFocus requires no parameters. This function returns an
integer value that represents the handle to the control. Use GetFocus
to get a handle to the control that currently has the focus.
hWd% = GetFocus()
After you have received the handle to the text box control, you can
call GetWindowLong to retrieve the style flags for the control by
using the second parameter of GWL_STYLE. Once you have the style
flags, you can use the bit-wise OR operation to set the ES_PASSWORD
style.
StyleFlags& = GetWindowLong (hWd%, GWL_STYLE)
StyleFlags& = StyleFlags& OR ES_PASSWORD
After adding the password style to the existing style for the control,
you can call SetWindowLong to change the style associated to the
control. You would call SendMessage with the message parameter of
ES_SETPASSWORDCHAR to inform the control what character is to be used
as the password mask; the default character is an asterisk (*).
StyleFlags& = SetWindowLong (hWd%, GWL_STYLE, StyleFlags&)
PasswordMask% = Asc("*")
SendMessage (hWd%, ES_SETPASSWORDCHAR, PasswordMask%, 0&)
To create a text box with the password style within Visual Basic,
create a text box with the name Text1 on Form1.
Declare the following Windows API functions and CONST variables in the
Global section of your code:
Declare Function GetFocus Lib "User" () As Integer
Declare Function GetWindowLong Lib "User" (ByVal hWd%, ByVal nIndex%)
As Long
Declare Function SetWindowLong Lib "User" (ByVal hWd%, ByVal nIndex%,
ByVal dwNewLong&) As Long
Declare Function SendMessage Lib "User" (ByVal hWd%, ByVal wMsg%,
ByVal wParam%, ByVal lParam&) As Long
Global Const WM_USER = &H400
Global Const EM_SETPASSWORDCHAR = WM_USER + 28
Global Const ES_PASSWORD = &H20
Global Const GWL_STYLE = -16
Note: Each Declare statement above must be written on just one line.
Include the following code in the (general) section of the Form1
module:
Sub Make_Password_Control (Flag As Integer, PasswordMask As Integer)
Dim hWd As Integer ' Window Handle for the control
Dim StyleFlags As Long ' Window Style for the control
If Not Flag Then
' The control should have a STATIC flag to minimize the
' execution of the code. We don't want to perform this code
' all the time, just once.
Flag = Not Flag
hWd = GetFocus()
StyleFlags = GetWindowLong(hWd, GWL_STYLE)
StyleFlags = StyleFlags Or ES_PASSWORD
StyleFlags = SetWindowLong(hWd, GWL_STYLE, StyleFlags)
StyleFlags = SendMessage(hWd, EM_SETPASSWORDCHAR, PasswordMask, 0&)
End If
End Sub
Include the following code in the Text1_GotFocus event in the Form1
module:
Sub Text1_GotFocus ()
Static Already_Password As Integer
Make_Password_Control Already_Password, Asc("*")
End Sub
Title: How to Get "HWnd" Handle for a Control by Using GetFocus API
Document Number: Q71799 Publ Date: 16-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Microsoft Visual Basic does not provide access to the Windows Handle
(hWnd) for any control other than the Form. By using the Windows API
GetFocus function, you can retrieve the handle to most Visual Basic
controls.
This information applies to Microsoft Visual Basic Programming System
version 1.00 for Windows.
More Information:
Visual Basic provides a "hWnd" property for the Form, but none of the
provided controls has this property. By using the Windows API GetFocus
function and the Visual Basic SetFocus method you can obtain the
"hWnd" for most Visual Basic controls. With the exception of the Frame
and Label controls, neither of these controls can receive the focus
for user input and do not support the Visual Basic SetFocus method.
The Visual Basic SetFocus method allows the changing of the input
focus to a specific control, rather then waiting for the user to
select the desired control manually. The following code will change
the focus to the Command Button "Command1" on the Form:
Command1.SetFocus
The GetFocus function requires no parameters. The GetFocus function
returns an integer value that represents the handle to the control.
Use GetFocus to get a handle to the control that currently has the
focus:
hWd% = GetFocus() ' HWnd is reserved word in Visual Basic, so you
' must use a different name, such as hWd%
Most Windows API functions require the handle (hWnd) of the window
that is to be acted upon.
For examples of using the Windows API GetFocus function in Visual
Basic, query on the following word:
GETFOCUS
Title: "Overflow" in VB Drawing Circle Segment with Radius of Zero
Document Number: Q73280 Publ Date: 16-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: MS-DOS

Summary:
When using the Microsoft Visual Basic version 1.0 Circle statement to
draw a segment of a circle with a radius of 0, an "Overflow" error
incorrectly occurs.
Microsoft has confirmed this to be a problem with Microsoft Visual
Basic programming system version 1.0 for Windows. We are researching
the problem and will post new information here as it becomes
available.
More Information:
The following statement demonstrates the problem:
Circle (0,0), 0,, 4, 5
When you run the above statement, an "Overflow" error incorrectly
occurs.
In contrast, using the Circle statement to draw an entire circle of
radius 0 works correctly without an error (correctly drawing nothing);
for example:
Circle (0,0), 0
Title: How to Scroll VB Text Box Programmatically and Specify Lines
Document Number: Q73371 Publ Date: 16-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
By making a call to the Windows API function SendMessage, you can
scroll text a specified number of lines or columns within a Visual
Basic text box. By using SendMessage, you can also scroll text
programmatically, without user interaction. This technique extends
Visual Basic's scrolling functionality beyond the built-in statements
and methods. The sample program below shows how to scroll text
vertically and horizontally a specified number of lines.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
Note that Visual Basic itself does not offer a statement for scrolling
text a specified number of lines vertically or horizontally within a
text box. You can scroll text vertically or horizontally by actively
clicking on the vertical and horizontal scroll bars for the text box
at run time; however, you do not have any control over how many lines
or columns are scrolled for each click of the scroll bar. Text always
scrolls one line or one column per click on the scroll bar.
Furthermore, no built-in Visual Basic method can scroll text without
user interaction. To work around these limitations, you can call the
Windows API function SendMessage, as explained below.
Example
-------
To scroll the text a specified number of lines within a text box
requires a call to the Windows API function SendMessage using the
constant EM_LINESCROLL. You can invoke the SendMessage function from
Visual Basic as follows:
r& = SendMessage& (hWd%, EM_LINESCROLL, wParam%, lParam&)
hWd% The window handle of the text box.
wParam% Parameter not used.
lParam& The low-order 2 bytes specify the number of vertical
lines to scroll. The high-order 2 bytes specify the
number of horizontal columns to scroll. A positive
value for lParam& causes text to scroll upward or to the
left. A negative value causes text to scroll downward or
to the right.
r& Indicates the number of lines actually scrolled.
The SendMessage API function requires the window handle (hWd% above)
of the text box. To get the window handle of the text box, you must
first set the focus on the text box using the SetFocus method from
Visual Basic. Once the focus has been set, call the GetFocus API
function to get the window handle for the text box. Below is an
example of how to get the window handle of a text box.
'The following appears in the general declarations section of the
'form:
Declare Function GetFocus% Lib "USER" ()
'Assume the following appears in the click event procedure of a
'command button called Scroll.
Sub Command_Scroll_Click ()
OldhWnd% = GetFocus () 'Store the window handle of the
'control that currently has the
'focus.
Text1.SetFocus
hWd% = GetFocus()
End Sub
To scroll text horizontally, the text box must have a horizontal
scroll bar, and the width of the text must be wider than the text box
width. Calling SendMessage to scroll text vertically does not require
a vertical scroll bar, but the length of text within the text box
should exceed the text box height.
Below are the steps necessary to create a text box that will scroll
five vertical lines or five horizontal columns each time you click the
command buttons labeled "Vertical" and "Horizontal":
1. From the File menu, choose New Project (ALT+F+N).
2. Double-click on Form1 to bring up the code window.
3. Add the following API declaration in the General Declarations
section of Form1. Note that you must put all Declare statements on a
separate and single line. Also note that SetFocus is aliased as
PutFocus because there already exists a SetFocus method within Visual
Basic.
Declare Function GetFocus% Lib "user" ()
Declare Function PutFocus% Lib "user" Alias "SetFocus" (ByVal
hWd%)
Declare Function SendMessage& Lib "user" (ByVal hWd%,
ByVal wMsg%,
ByVal wParam%,
ByVal lParam&)
4. Create a text box called Text1 on Form1. Set the MultiLine
property to True and the ScrollBars property to Horizontal (1).
5. Create a command button called Command1 and change the Caption
to "Vertical".
6. Create a another command button called Command2 and change the
Caption to "Horizontal".
7. From the General Declarations section of Form1, create a procedure
to initialize some text in the text box as follows:
Sub InitializeTextBox ()
Text1.Text = ""
For i% = 1 To 50
Text1.Text = Text1.Text + "This is line " + Str$(i%)
'Add 15 words to a line of text
For j% = 1 to 10
Text1.Text = Text1.Text + " Word "+ Str$(j%)
Next j%
'Force a carriage return (CR) linefeed (LF)
Text1.Text = Text1.Text + Chr$(13) + Chr$(10)
x% = DoEvents()
Next i%
End Sub
8. Add the following code to the load event procedure of Form1:
Sub Form_Load ()
Call InitializeTextBox
End Sub
9. Create the actual scroll procedure within the General Declarations
section of Form1 as follows:
'The following two lines must appear on a single line:
Function ScrollText& (TextBox As Control, vLines As Integer, hLines
As Integer)
Const EM_LINESCROLL = &H406
'Place the number of horizontal columns to scroll in the high-
'order 2 bytes of Lines&. The vertical lines to scroll is
'placed in the low-order 2 bytes.
Lines& = Clng(&H10000 * hLines) + vLines
'get the window handle of the control that currently has the
'focus, Command1 or Command2.
SavedWnd% = GetFocus%()
'set focus to the passed control (Text control)
TextBox.SetFocus
'get the handle to current focus (Text control)
TextWnd% = GetFocus%()
'scroll the lines
Success& = SendMessage(TextWnd%, EM_LINESCROLL, 0, Lines&)
'restore the focus to the original control, Command1 or
'Command2
r% = PutFocus% (SavedWnd%)
'return the number of lines actually scrolled
ScrollText& = Success&
End Function
10. Add the following code to the click event procedure of Command1
labeled "Vertical":
Sub Command1_Click ()
'Scroll text 5 vertical lines upward
Num& = ScrollText&(Text1, 5, 0)
End Sub
11. Add the following code to the click event procedure of Command2
labeled "Horizontal":
Sub Command2_Click ()
'Scroll text 5 horizontal columns to the left
Num& = ScrollText&(Text1, 0, 5)
End Sub
12. Run the program. Click the command buttons to scroll the text five
lines or columns at a time.
Title: "[" May Incorrectly Sort in List/Combo Box if Sorted=True
Document Number: Q73838 Publ Date: 16-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
An example below demonstrates a problem using the Sorted property to
sort a string beginning with a bracket ([) in either a list box or
combo box in Microsoft Visual Basic programming system version 1.0 for
Windows.
This sorting problem is actually caused by Microsoft Windows 3.0
(buglist3.00) and is not caused by Visual Basic. Microsoft is
researching this problem and will post new information here as it
becomes available.
More Information:
Steps to Reproduce Problem
--------------------------
1. In the Visual Basic environment, from the File menu, choose New
Project.
2. Place two list boxes or two combo boxes on the form.
3. Select from the Properties Bar the Sorted property for either the
two list boxes or two combo boxes to True.
Note: Do not invoke List1.Sorted = -1 within the code of an event
procedure because this causes the following run-time error:
"Sorted" property cannot be set at runtime
4. Add some code to the Form_Click event procedure. Below are two
separate examples of the code to add, depending on if you are using
list boxes or combo boxes:
Sub Form_Click () Sub Form_Click ()
List1.AddItem "[" Combo1.AddItem "["
List1.AddItem "\" Combo1.AddItem "\"
List1.AddItem "a" Combo1.AddItem "a"
List2.AddItem "a" Combo2.AddItem "a"
List2.AddItem "\" Combo2.AddItem "\"
List2.AddItem "[" Combo2.AddItem "["
End Sub End Sub
5. From the Run menu, choose Start, or press F5 to run the code.
6. Click on the form to see the sequence "a [ \" in the first
list box or combo box and see the different sequence "[ \ a" in the
second list box or combo box.
This reveals an inconsistency with an internal Windows 3.0 sorting
routine. If you replace the bracket character with the character "b", the
two boxes correctly sort in the same order (\ a b). The problem is
with sorting the bracket character.
Title: Initial ForeColor/BackColor on Color Palette Can Be Reversed
Document Number: Q74265 Publ Date: 16-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
This article explains a problem with the Color Palette in Microsoft
Visual Basic programming system version 1.0. The following steps
reproduce the problem:
1. Start Visual Basic; the default Form1 will display.
2. From the File menu, choose Save Project As, and follow the prompts
to save under the default name Form1.frm, followed by Project1.mak.
3. From the Window menu, choose Color Palette. Notice the default
colors presented for the background and foreground in the
left box. The foreground is black and the background is white.
4. Exit Visual Basic.
5. From the Program Manager's File menu, choose the Run command and
enter the following path:
C:\VB\Project1.mak
6. This should begin running Visual Basic with the previously saved
example Project1.mak that you saved in step 2.
7. Notice the Color Palette is displayed differently. The background
is now black instead of white and the foreground is now white
instead of black.
This problem occurs only when a project is run from the command line.
The above problem can be corrected by adding one more step: View the
Form by selecting Form1.frm from the Project1 Window. This causes the
Color Palette to be displayed correctly with the background being
white instead of black.
Microsoft has confirmed this to be a problem with Microsoft Visual
Basic programming system version 1.0. We are researching this problem
and will post new information here as it becomes available.
Title: "[" May Incorrectly Sort in VB List/Combo Box If Sorted=True
Document Number: Q74132 Publ Date: 16-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
An example below demonstrates a problem using the Sorted property to
sort a string beginning with a bracket "[" in either a list box or
combo box in Microsoft Visual Basic programming system version 1.0 for
Windows.
This sorting problem is actually caused by Microsoft Windows 3.0
(buglist3.00) and is not caused by Visual Basic. Microsoft is
researching this problem and will post new information here as it
becomes available.
More Information:
The following steps duplicate the problem:
1. In the Visual Basic environment, choose New Project from the File
menu.
2. Place two list boxes or two combo boxes on the form.
3. From the Properties Bar, set the Sorted property for either the two
list boxes or two combo boxes to True.
Note: Do not invoke List1.Sorted = -1 within the code of an event
procedure because this causes the run-time error "'Sorted'
property cannot be set at run time."
4. Now add some code to the Form_Click event procedure. Below are two
separate examples of the code to add depending on if you are using
list boxes or combo boxes:
Sub Form_Click () Sub Form_Click ()
List1.AddItem "[" Combo1.AddItem "["
List1.AddItem "\" Combo1.AddItem "\"
List1.AddItem "a" Combo1.AddItem "a"
List2.AddItem "a" Combo2.AddItem "a"
List2.AddItem "\" Combo2.AddItem "\"
List2.AddItem "[" Combo2.AddItem "["
End Sub End Sub
5. Run the code by pressing the F5 function key or choosing Start from
the Run menu.
6. Click on the form to see the sequence "a [ \" in the first list box
or combo box and to see the different sequence "[ \ a" in the
second list box or combo box.
This reveals an inconsistency with an internal Windows 3.0 sorting
routine. If you replace the character "[" with the character "b", the
two boxes correctly sort in the same order: "\ a b". The problem is
with sorting the "[" character.
Title: Extra Click Required to Return Focus to Code and Select Text
Document Number: Q74294 Publ Date: 16-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary
You must use an extra click when returning focus from the Menu bar,
Toolbox, or the Properties bar to the current code window and then
attempting to either select text or set the insertion point. Contrary
to the standard Windows convention, which requires only one mouse
click and hold to accomplish this, Visual Basic 1.0 requires you to
click once to set the focus to the code window, and then again to
position the insertion point or select text.
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
More Information:
To duplicate this problem, start with a new project in the Visual
Basic environment:
1. Double-click on Form1 to to open the Form1_Click procedure code
window.
2. Click on Visual Basic's Main menu, Properties bar, or Toolbox.
3. Try to position the insertion point or select text in the
Form1_Click code window. The first click merely shifts the focus
to the code window, but the insertion point is not positioned in
the window, nor is any text selected.
You must release the mouse button and click again to select text or
place the insertion point. The problem also occurs in the Copy/Paste
or Cut/Paste process. When you attempt to Paste, you must click a
second time to place the insertion point where desired for the Paste.
Title: If Directory Deleted, Directories Empty in Save Project As Box
Document Number: Q74192 Publ Date: 16-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
The following is a small user-interface problem with the Save Project
As dialog box in Microsoft Visual Basic programming system version 1.0
for Windows.
If you currently have a project loaded in Visual Basic and, from a
simultaneous DOS session in Windows, you delete that project and its
subdirectory, then the next Save Project As command will incorrectly
display an empty Directories list box. Subsequent Save Project As
commands correctly show the Directories list box.
Microsoft has confirmed this problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
More Information:
The following steps reproduce the problem.
1. Go to a DOS prompt and change directory to the Visual Basic
directory (CHDIR \VB). From this directory, make a new directory
with the MKDIR command; for example, MKDIR TEST.
2. Now go back into Windows. From Visual Basic's File menu, choose
Save Project As. Choose Yes to save the form as Form1.Frm. Next,
save the form under the following path:
C:\VB\TEST\Form1.Frm
3. After you press ENTER or choose OK, another message will display,
asking you to save the Project1.Mak. Choose OK, and enter the path:
C:\VB\TEST\Project1.Mak
4. Minimize Visual Basic and activate a DOS prompt box from Windows.
From the directory C:\VB\TEST you should see the Project1.Mak and
Form1.Frm files. Delete these files with DEL *.* and answer Y.
Change directories to the C:\VB directory (CHDIR ...). Remove the
TEST directory with the command RMDIR TEST. Now EXIT from DOS and
return to your Visual Basic session within Windows.
5. Now try to save the project by choosing Save Project As. A message
will correctly state "Path not found: 'C:\VB\TEST'". Choose OK;
then you will see a Save Project As window displayed with an empty
"File Name", but the "Directories" list box will incorrectly be
blank. The problem is minor, since subsequent Save Project As
commands correctly display directories in the "Directories" list
box.
Title: "UAE" Changing Display of DOS Window When VB Is at Breakpoint
Document Number: Q74193 Publ Date: 16-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
This information applies to Microsoft Visual Basic programming system
version 1.0 for Microsoft Windows.
When using some Windows display drivers, the following steps may cause
Microsoft Visual Basic to abort with an "UNRECOVERABLE APPLICATION
ERROR:"
1. Start Microsoft Visual Basic.
2. Add a line of code to the Form_Click event procedure, such as
"X = 5".
3. Set a break point on the line added in step 2.
4. Start a simultaneous DOS session in Windows.
5. Run the Visual Basic program (F5); click on the form to stop at
the break point.
6. Activate (double-click) the DOS window.
7. Press ALT+ENTER to change the DOS window to a full screen window.
After pressing ALT+ENTER to change the DOS window to a full screen DOS
session, Microsoft Visual Basic may quit with an "UNRECOVERABLE
APPLICATION ERROR." This behavior is a result of problems with
certain Windows display drivers, and not a problem with Visual Basic.
Title: Can Click in Code Window Without Activating it, in VB.EXE
Document Number: Q74194 Publ Date: 16-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
If you have both a form and code window present at design time in
Microsoft Visual Basic with the current focus on the form, clicking on
the upper or lower edge of the splitter bar in the code window will
fail to shift the focus to the code window. Clicking anywhere else on
the code window correctly shifts the focus and activates the code
window.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
To reproduce this problem in Visual Basic, choose the New Project
option from Visual Basic's File menu. Double-click on Form1 to open a
code window, then click on Form1 to return focus to the form. Now
place the tip of the mouse pointer on the upper or lower edge of the
code window's splitter bar such that the pointer remains an arrow, and
is not an I-beam pointer or splitter pointer. Clicking now fails to
shift the focus to the code window. You can click anywhere else in the
code window and the code window will correctly become the active
window.
Note that the "splitter bar" (the horizontal border just above the
editing area and just above the vertical scroll bar) allows you to
split the code window into two parts, which allows you to view two
different sections of code at once.
Title: Why Output Might Not Display from VB Form_Load Procedure
Document Number: Q71101 Publ Date: 22-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Any graphics or output done within a Form_Load procedure will not
display on the form unless you first make the form visible with the
Form1.Show method or if you set the form's AutoRedraw property to be
true (non-zero).
This information applies to Microsoft Visual Basic Programming System
version 1.0 for Windows.
More Information:
When the Form_Load procedure executes (at the beginning of the
program), by default the form is not yet displayed. Therefore, during
the Form_Load event, no graphics are displayed to the nonexistent form
unless you first Show the form (at run time) or set the form's
AutoRedraw property (at design time or run time).
A better approach to drawing graphics to the form is to have the
graphics drawn to the form during a Sub Form_Paint procedure. This
allows the Form.AutoRedraw property to be set to FALSE, increasing the
speed performance of your program. Visual Basic does not have to
refresh the screen image of your form as it does when a form is
overlapped with another window. You (as the programmer) are
responsible for refreshing the form, and Sub Form_Paint is the most
logical place to handle this situation.
Listed below are three examples of drawing graphics to your form. The
first example shows how the graphics fail to be displayed to the form
when drawn from within a Form_Load event procedure. The second example
shows how you could draw a circle to the form, but the Form.AutoRedraw
property must be set to TRUE for the circle to be retained in the
event the form needs to be refreshed. The third example is the best
approach; it is the fastest and most efficient of the three.
For each example below, add the following Function procedure as a code
procedure to Form1.
Function Minimum! (n1!, n2!)
If n1! < n2! Then
Minimum! = n1!
Else
Minimum! = n2!
End If
End Function
Example 1
---------
No graphic is displayed to the form in the following:
Sub Form_Load
Row = Form1.ScaleHeight / 2
Col = Form1.ScaleWidth / 2
Radius = Minimum(Row, Col) ' Function that returns smaller number.
Form1.Circle (Col, Row), Radius
End Sub
Example 2
---------
This example will work, but the AutoRedraw property of Form1 must be
TRUE for the screen to refresh properly:
Sub Form_Load
Form1.Show
Form1.AutoRedraw = -1
Row = Form1.ScaleHeight / 2
Col = Form1.ScaleWidth / 2
Radius = Minimum(Row, Col) ' Function that returns smaller number.
Form1.Circle (Col, Row), Radius
End Sub
Example 3
---------
This is the best example. AutoRedraw should be set to FALSE for
better speed and efficiency.
Sub Form_Paint
Row = Form1.ScaleHeight / 2
Col = Form1.ScaleWidth / 2
Radius = Minimum(Row, Col) ' Function that returns smaller number.
Form1.Circle (Col, Row), Radius
End Sub
Title: After Access (ALT+) Key, First Input to Combo Box Is Ignored
Document Number: Q73040 Publ Date: 17-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: MS-DOS

Summary:
In Microsoft Visual Basic version 1.0, if a combo box has the focus
and you use an access key (ALT + another key) to set the focus to
another object, and you then give the focus back to the combo box
(either by tabbing or using the mouse), then the next text key you
enter into the combo box will be ignored.
Microsoft has confirmed this problem in Microsoft Visual Basic version
1.0 programming system for Windows. We are researching this problem
and will post new information here as it becomes available.
More Information:
Steps to Reproduce Problem
--------------------------
1. Start Visual Basic.
2. On a form, create a combo box and a command button.
3. Change the caption property of the command button to "&Command1".
This makes ALT+C the access key for Command1.
4. Run the application.
Note that when you type ALT+C and then reset the focus back to the combo
box, either with the mouse or by using the TAB key, the next key you
press to enter text in the combo box will be ignored.
This problem occurs for both drop-down and simple combo boxes, styles
0 and 1.
Title: Procedure Name Remaining in Procedure Combo Box After Deletion
Document Number: Q73653 Publ Date: 18-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
If you delete the SUB and END SUB (or FUNCTION and END FUNCTION) lines
in a user-defined procedure and leave one or more blank lines in
that procedure's code window, the procedure name remains in the combo
box containing the procedure names (hereafter referred to as the
procedure combo box).
Also, if you delete the SUB and END SUB lines for a standard Visual
Basic event procedure and you leave one or more blank lines, the code
will remain blank for that procedure instead of returning to the
standard SUB and END SUB syntax for that event.
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
More Information:
Steps to Reproduce Problem
--------------------------
1. From the File menu, select New Project (ALT, F, N).
2. Double-click on the default form (Form1).
3. From the General Declarations section of Form1, do the
following:
a. Type "Sub MySub" (without the quotation marks) and press ENTER.
b. Insert a least one blank line between the SUB ... END SUB
statements.
c. Delete just the statements Sub MySub () and End Sub, and leave
at least one blank line between them.
The procedure name MySub will still appear in the procedure combo box;
however, when you switch to the code window for the procedure, it will
appear to be empty. The blank line that was added in step 3.b. above
will still be present.
To remove the procedure name MySub from the procedure combo box,
delete all of the blank space within the code window.
Title: Comments and Blank Lines Increase Size of VB 1.0 .EXE File
Document Number: Q73697 Publ Date: 17-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Each line containing blank space or a comment in any code window of a
Visual Basic application adds 2 bytes to the size of the compiled
executable file (.EXE). This is not a problem with Visual Basic, but
rather it is part of Visual Basic's design.
This information applies to the Visual Basic programming system
version 1.0 for Windows.
More Information:
The 2 byte overhead for each line containing blank space or a comment
is generated as part of the pseudo-code for the application in the
VB.EXE development environment. The program is run in "interpreted
mode" based on this pseudo-code. Because an .EXE program is generated
based on this pseudo-code (in other words, Visual Basic does not use a
compiler and linker), the 2 byte overhead is copied to the .EXE
program. The only workaround for this behavior is to remove comments
and blank lines before compiling the Visual Basic project.
Title: Cannot Tile or Cascade Programs Created with Visual Basic
Document Number: Q73698 Publ Date: 17-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Applications that have been created with Microsoft Visual Basic 1.0 do
not tile or cascade as do other Windows applications.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
Visual Basic creates applications that are pop-up windows. This window
style does not respond to the tile or cascade message sent from the
Windows 3.0 Task List or other applications that support the cascade
and tile features.
You can verify this action by launching two applications created in
Visual Basic, then bringing up the Windows Task List by pressing
CTRL+ESC, and from the Task List choosing either the Cascade or Tile
button. Notice that nothing has changed in the arrangements of these
two Visual Basic application windows. You may have expected the Visual
Basic application windows to cascade or tile as other Windows
applications do, but they will not do so.
Title: Some VB.EXE Main Menu Commands Can Be Invisible at Run Time
Document Number: Q73699 Publ Date: 17-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
If you shrink the width of VB.EXE's main menu (and Properties Bar) such
that menu commands automatically wrap to the next line, wrapped
menu commands may be invisible at run time in the VB.EXE environment.
You can work around this visibility problem by using the ALT key to
access the invisible menu commands on the shrunken menu, or by
avoiding shrinking the width beyond the point where the menus wrap.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
Steps to Reproduce Problem
--------------------------
1. Start Visual Basic (VB.EXE).
2. Place the mouse pointer on the far right side of the Properties
Bar such that the mouse changes to a double-headed pointer, ready
for resizing the Properties Bar.
3. Press and hold down the left button of the mouse and drag the right
edge of the Properties Bar toward the left side of the screen so that
the Bar ends up being about 3 inches in width, then release the mouse
button. This should cause the Window and Help menu commands to
automatically wrap the next line.
4. From the Run menu, choose Start, or press F5. The Window and Help
menus are now invisible because they are wrapped beyond the edge of
their window.
5. Click on the Immediate Window (in the lower right corner) and bring
the Immediate Window in front of the Form1 window.
6. Try bringing up the either the Window menu by pressing ALT+W or the
Help menu by pressing ALT+H. You will see the appropriate menu on the
screen, but it will appear disconnected below the Main Menu (or
Properties Bar) even though the menu is still functional. If you don't
perform step 5, you won't be able to select the invisible menus with
the ALT key (or with the mouse).
This behavior is due to the way that Windows 3.0 manipulates menus and
the design of the Microsoft Visual Basic 1.0 interface. To avoid this
behavior, Microsoft recommends keeping the main menu sufficiently wide
such that menus are not wrapped.
Title: TABs Paste Incorrectly as ] to VB.EXE's Immediate Window
Document Number: Q73700 Publ Date: 17-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
TAB characters may Paste (from the Windows Clipboard) incorrectly into
the Immediate Window in Microsoft Visual Basic version 1.0. (TAB
characters may incorrectly Paste as pipe []| symbols.)
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.00 for Windows. We are researching this
problem and will post new information here as it becomes available.
More Information:
Steps to Reproduce Problem
--------------------------
1. From Windows 3.0, run NOTEPAD.EXE and enter the following text:
a a
This will be displayed in the following format:
a a
2. Select the text with the mouse and choose Copy from Notepad's
Edit menu to copy the text to the Windows Clipboard.
3. Start Visual Basic and press F5 to run the blank program (or from
the Run menu, choose Start).
4. Break the program by pressing CTRL+BREAK, then click the mouse on
the Immediate Window.

5. Press SHIFT+INSERT to enter the selected text into the Immediate
Window. Observe that the Immediate Window incorrectly displays the
following text:
a]a
instead of displaying the following:
a a
6. If you end the program (by choosing the End command from the Run
menu), you will be able to successfully paste (SHIFT+INSERT) the
correct text into any code window:
a a
Title: How to Optimize Size and Speed of Visual Basic Applications
Document Number: Q73798 Publ Date: 17-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
This article describes how to optimize size and speed for applications
in Microsoft Visual Basic programming system version 1.0 for Windows.
More Information:
Below are guidelines to help increase speed, available resources,
available RAM, and available disk space in Visual Basic:
Increase Speed
--------------
- Preload forms.
- Store graphics as bitmaps.
- Place debug routines in a separate module.
- Use dynamic link library (DLL) routines.
Increase Available Resources
----------------------------
- Create simulated controls using a graphic object.
- Draw graphics images during run time.
Increase Available RAM
----------------------
- Use Integer variables instead of Single variables.
- Create dynamic arrays to free arrays when not needed.
- Drop/unload controls and forms when not needed.
- Use local variables.
Increase Disk Space
-------------------
- Build controls at load time.
- Minimize header size.
- Delete unnecessary functions and subroutines.
- Delete unused objects and associated methods.
Title: No Edit Menu Access for Property Entry; Use Edit Shortcut Keys
Document Number: Q73800 Publ Date: 17-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
The following information applies to Microsoft Visual Basic
programming system version 1.0 for Windows.
The Properties Bar entry window was not designed to handle the Edit
menu commands (such as Cut, Copy, Paste, and Undo) when chosen with
the mouse. The Edit menu commands affect the controls on the form,
not the Properties Bar entry window (even if you first select text in
the Properties Bar entry window before choosing the Edit menu with the
mouse).
Instead of choosing Edit commands with the mouse, you can select the
desired text in the Properties Bar entry window and use the Edit
shortcut keys, as follows:
Command Shortcut Keys
------- -------------
Cut SHIFT+DELETE
Copy CTRL+INSERT
Paste SHIFT+INSERT
Undo ALT+BACKSPACE
(NUM LOCK needs to be off if you select the DELETE or INSERT key
from the numeric keypad.)
More Information:
Example: Edit Menu Cannot Affect Properties Bar Entry Window
------------------------------------------------------------
1. Start Visual Basic.
2. From the File menu, choose New Project.
3. Double-click on a label box from the Toolbox (symbolized by a
capital A in script). This should display a label box on the
form.
4. With the mouse, select the text fragment "Lab" from the "Label1"
Caption in the Properties Bar entry window, and choose Copy from
the Edit menu.
Note: While you may have thought you just copied "Lab" into the
Clipboard, you actually copied the entire Label1 control (from
the form) into the Clipboard. Clicking the Edit menu anywhere
outside the Properties Bar entry window causes the focus to
revert back to the Label1 control on the form.
5. Click on the "Form1" text appearing in the Properties Bar entry
window to set the focus there.
6. From the Edit menu, choose Paste (again, clicking the Edit menu or
anywhere outside the Properties Bar entry window causes the focus to
revert back to the Label1 control on the form.) This causes the
following message box:
"You already have a control named 'Label1'. Do you want to
create a control array?".
Select either the Yes or No command button. Notice that
another copy of the Label1 box will appear in the upper left
corner of the form.
Instead of choosing Edit commands with the mouse, you can select the
desired text in the Properties Bar entry window and use the Edit
shortcut keys. For example, you can select text in the Properties Bar
entry window, then press CTRL+INSERT (while NUM LOCK is off) to copy
text to the Clipboard. You can press SHIFT+INSERT to paste Clipboard
text into the Properties Bar entry window. You can press ALT+BACKSPACE
to Undo a Cut, Copy, or Paste.
Title: Visual Basic Applications Cannot Act as Windows Shell
Document Number: Q73801 Publ Date: 17-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
An application created by Visual Basic cannot be used as the Windows
shell. Attempting to run an application as the Windows shell results
in a Windows "Unrecoverable Application Error" (UAE) message. This is
expected behavior when attempting to run a Visual Basic application as
the Windows shell. This is not a problem with Visual Basic, but rather
a design limitation. This information only applies to Visual Basic
.EXE programs.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
A user-defined shell application can be specified in the Windows
system initialization (SYSTEM.INI) file. The default shell is
PROGMAN.EXE, or the Program Manager. If a Visual Basic program is
specified as the customized Windows shell, a Windows UAE will occur on
an attempt to run Windows from the DOS command line.
A Visual Basic application cannot be run as the Windows shell because
it does not contain the special set of startup code required by a
Windows shell application. The only way to create a Windows shell
application is to use the C Compiler and the Windows Software
Development Kit (SDK) to write a non-Visual Basic application.
Steps to Reproduce Problem
--------------------------
Warning: The following steps require changing the Windows system
initialization file (SYSTEM.INI) in a manner such that Windows will
not run successfully unless the file is restored from DOS. The file
can be restored from DOS by using a backup copy of the SYSTEM.INI file
or by restoring the SYSTEM.INI file with a text editor from DOS.
1. Start Visual Basic.
2. From the File menu, choose New Project.
3. From the File menu, choose Make .EXE program.
4. Choose OK to select Project1.EXE as the .EXE filename.
5. Exit Visual Basic.
6. Start Windows Notepad.
7. From the File menu, choose Open.
8. In the Filename text box, type "c:\windows\system.ini" (without
the quotation marks) or the path and filename of the SYSTEM.INI
file on your system.
9. Choose OK.
10. Change the line the reads "shell=progman.exe" to
"shell=c:\vb\project1.exe", or the appropriate path to the file
created in step 4 above.
11. From the File menu, choose Save.
12. Exit Notepad.
13. From the Windows Program Manager File menu, choose Exit (you
should exit back to DOS).
14. At the DOS prompt, run Windows.
When you attempt to run Windows, a UAE will occur. You will need to
reboot your computer and modify the SYSTEM.INI with a text editor from
DOS such that the line "shell=c:\vb\project1.exe" appearing in the
SYSTEM.INI is changed back to "shell=progman.exe".
Title: Deleting VB Control Moves Associated Code to Object: (General)
Document Number: Q73808 Publ Date: 17-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
When you delete a control in the Visual Basic environment, the code
that you wrote for that control is not deleted, but is instead moved
to the Object: (General) area for code. Some programmers may not
realize that these detached (unused) procedures still exist and
consume memory. The detached code is available for calling, copying,
or reuse. For example, when you add a control that shares the same
name as a detached procedure, the detached event procedure
reassociates with that control.
If you want to delete both the control and its associated code, you
need to manually select and delete the code in each event procedure
for that control in addition to deleting the control itself.
This behavior is by design in Microsoft Visual Basic programming
system version 1.0 for Windows.
More Information:
The following example demonstrates that your code goes into the
Object: (General) area after you delete the associated control (or
object):
1. From the File menu, choose New Project.
2. Double-click on a command button from the Toolbox. This puts a
Command1 button on your form.
3. Double-click on the Command1 button. This brings up the code window
for the Command1_Click event procedure.
4. Enter the following code inside the Command1_Click procedure:
Sub Command1_Click()
Print "Hello" 'Enter this statement
End Sub
5. Press F5 to run your code. Click on the Command1 button to see the
text "Hello" display on Form1 in the upper left corner. From
the Run menu, choose End to stop the program.
6. Click on the Command1 button on Form1 to set the focus there and
either press DELETE or choose the Delete command from the Edit menu.
This deletes the Command1 button from the form.
At this point, some programmers may incorrectly assume that the
code associated with the Command1 button was also deleted.
Actually, the code associated with any deleted object is
automatically moved into the Object: (general) area of the Code
window for that form. You can find the detached procedures in the
Code window by choosing (general) from the Object: box, and
choosing the procedures from the Proc: box. (Click on the DOWN
arrow symbol on the right of the Object: and Proc: boxes to see
your choices.)
Title: Pull-Down on Drive Box Disabled if Width Changed at Run Time
Document Number: Q73809 Publ Date: 17-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
If you change the Width property of a drive list box at run time, the
pull-down list of drives will no longer work.
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. Microsoft is researching
this problem and will post new information here as it becomes
available.
More Information:
Steps to Reproduce Problem
--------------------------
1. Start Visual Basic. Form1 will automatically display.
2. Put a drive list box on Form1.
3. In the Click event of Form1, add the following code:
Sub Form_Click ()
Drive1.Width = Drive1.Width * 2
End Sub
4. Run the application (press F5).
5. Click on the down arrow on the drive box to display the list.
6. Choose a drive; everything works as it should.
7. Click on Form1; the width of the drive box changes.
8. Click on the down arrow on the drive box.
Note that the list fails to display.
Title: Scroll Box Flashing Not Updated if Bar Resized with Focus
Document Number: Q73839 Publ Date: 17-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
There is a Microsoft Windows version 3.0 problem updating the flashing
indicator for the scroll box on a vertical scroll bar. This Windows
problem affects vertical scroll bars in Microsoft Visual Basic
programming system version 1.0 for Windows. This article describes how
to work around the problem.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
Steps to Reproduce Problem
--------------------------
1. Start Visual Basic and place a vertical scroll bar on a form.
2. Place the following code in the Form_Click event procedure:
Sub Form_Click ()
VScroll1.Height = VScroll1.Height * 2
End Sub
3. From the Run menu, choose Start, or press F5 to run the example.
4. Click and drag the flashing scroll box (on the scroll bar) to
the middle (down from the top).
5. Click on the form to execute the Form_Click procedure, which
doubles the height of the scroll bar. Observe that the scroll box
correctly moved to the middle of the longer scroll bar, but the
flashing indicator failed to also move.
You can work around the problem by doing the following:
1. In step 2 above, add additional code so that the Form_Click
procedure appears as follows:
Sub Form_Click ()
Const True = -1, False = 0
VScroll1.Height = VScroll1.Height * 2
VScroll1.Enabled = False
VScroll1.Enabled = True
End Sub
2. Follow the directions for steps 3, 4, and 5 above. You should
notice that the problem no longer exists. The flashing has
been updated correctly in the same position as the scroll box.
Microsoft has confirmed this to be a problem with Windows 3.0
(buglist3.00). We are researching this problem and will post new
information here as it becomes available.
Title: UAE Changing Text1.Text or Label1.Caption in Form_LinkClose
Document Number: Q74293 Publ Date: 18-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Running a Visual Basic application under the following conditions will
result in a Windows Unrecoverable Application Error (UAE) message:
1. A DDE (dynamic data exchange) conversation has been established
with another application where Visual Basic is the server (for
example, another application such as Microsoft Excel for Windows
initiates the DDE conversation.)
2. The Text, Picture, or Caption property of a Textbox, Picture, or
Label is set within the LinkClose event procedure of a form.
The problem occurs for a program run in the Visual Basic development
environment or run as an .EXE program. The problem does not occur if
the Visual Basic application acts as the client (that is, initiates
the conversation) in a DDE conversation.
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
More Information:
The problem occurs any time a control capable of DDE is changed within
the LinkClose event procedure of a form. Changing a control capable of
DDE causes Visual Basic to check all valid links. Because the
LinkClose event is incorrectly called before the DDE channel has been
fully deleted, Visual Basic treats the "partially" closed channel as a
valid link. A Windows UAE is generated as a result of Visual Basic
checking this invalid link.
To work around this problem, do the following:
1. Add a Timer control to the form.
2. Remove the code from the LinkClose event of Form1 and replace it
with:
Sub Form_LinkClose ()
Timer1.Enabled = -1
Timer1.Interval = 10
End Sub
3. Add the following code to the Timer event of Timer1:
Sub Timer1_Timer ()
Label1.Caption = "new caption"
'or Text1.Text = "new text" if using text box
Timer1.Enabled = 0
End Sub
When this is run and a LinkClose event occurs, the LinkClose event
will be allowed 10 milliseconds to finish, after which the desired
code will be executed (in the timer event) with no UAE.
Steps to Reproduce Problem
--------------------------
1. Start Microsoft Word for Windows (WINWORD.EXE).

2. From the Macro menu, choose Edit.
3. Type "autoexec" (without the quotation marks) as the name of the
macro you want to create, and press ENTER.
4. Add the following lines of code:
Sub MAIN 'sets up DDE link with VB
ChanNum = DDEInitiate("uaetest","form1")
Print ChanNum 'To confirm that link has been established
End Sub
5. Exit Word for Windows and save all changes as you are prompted.
6. Start Microsoft Visual Basic (Form1 will automatically be created
by default).
7. Put a label box on Form1 (or a text box on Form1).
8. Add the following code to the LinkClose event of Form1:
Sub Form_LinkClose ()
Label1.Caption = "new caption"
' or Text1.Text = "new text" if using TextBox
End Sub
9. From the File menu of Visual Basic, Save the file as Uaetest.Frm.
10. From the File menu of Visual Basic, Save the project as Uaetest.Mak.
11. Run Uaetest.
12. Start Windows. It will automatically run the macro to establish
the DDE link. This can be confirmed by the number 1 showing up on
the status line in Word for Windows.
13. Exit Word for Windows.
14. A UAE message will be displayed.
Title: Problem Clicking Properties List Box on Maximized Form
Document Number: Q74336 Publ Date: 22-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
At design time in the Microsoft Visual Basic (VB.EXE) environment, you
cannot assign properties to controls on a form that is maximized
unless the Code window is also displayed. The general problem is that
if you press the ALT key to activate the Properties bar over a form of
any size, you cannot access the Properties list box unless the Code
window is currently in front of the form.
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
More Information:
To work around the problem, put the Code window in front of the form
(this can be done by double-clicking a control), then you can access
the Properties list box and Settings box with the mouse. As an
alternative, when the form is not maximized and when the Properties
bar is at least partially visible, you can activate the Properties bar
with the mouse instead of with the ALT key.
Steps to Reproduce Problem
--------------------------
1. From the File menu, choose New Project.
2. Optionally, add any control (such as a picture box) to Form1.
3. Click the maximize button (in the upper right corner) on Form1 such
that it fills the entire screen.
4. Press the ALT key to display the Properties bar. You now can
correctly use the arrow keys or mouse to pull down the menus
and choose commands from the main menu. The problem is that if
you try to click on the Properties list box, the entire main menu
disappears, preventing you from changing properties.
Title: Spaces Can Make Words Wrap Too Soon in Windows Label Control
Document Number: Q74337 Publ Date: 22-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Embedded spaces can cause words to wrap too soon within a label box in
Microsoft Visual Basic programming system version 1.0 for Windows. The
problem is not with Visual Basic, but rather with Windows.
Microsoft has confirmed this to be a problem in Windows version 3.0
(buglist3.00). We are researching this problem and will post new
information here as it becomes available.
More Information:
Steps to Reproduce Problem
--------------------------
1. From the File menu, choose New Project.
2. Draw a label box on the form starting from the left side of
the form.
3. Set the width property of the label to 6975 twips (twips is the
default scale mode).
4. Set the height property of the label to 495 twips.
5. From the Properties list box, choose the Caption property for the
Label1 box. Enter the following caption in the Settings box, typing
10 spaces between digits instead of the ... (ellipses) shown:
1...2...3...4...5...6...7...8...9
As you can see, the 9 is incorrectly placed on the next line of the
label box, even though more than enough room exists to place the
entire caption in one line.
You can correct this problem by changing the width of the label to
7095 twips or more.
Title: File, List Controls 2 Pixels High at Design Time (Grid Align)
Document Number: Q74347 Publ Date: 19-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
When the "Align to grid" option is on, Visual Basic's list box and
file list box controls may not assume the correct minimum height when
you draw them shorter than two grid lines at design time. This can
result in a list box or file list box control that appears only 2
pixels (30 twips) high at design time. Visual Basic automatically
resizes other controls to the minimum height if they were drawn too
short.
Microsoft has confirmed this to be a problem with Microsoft Visual
Basic programming system version 1.0 for Windows. We are researching
this problem and will post new information here as it becomes
available.
The problem is not serious, because simply running the program causes
the control to correctly resize to the default minimum height.
More Information:
Steps to Reproduce Problem
--------------------------
1. Start Microsoft Visual Basic. From the Edit menu, choose Grid
Settings and activate (check) the "Align to grid" option.
2. Click on the list box control, or file list box control, in
the Toolbox.
3. Click on Form1 and drag the mouse across the form horizontally
without moving the mouse vertically.
4. Release the mouse button, and the control will fail to be resized
to the default minimum height (two grid lines). The control may be as
small as 2 pixels (30 twips) high.
Note that running the program causes the control to correctly resize
to the default minimum height (two grid lines).
Title: F5 in Run Mode with Focus on Main Menu Bar Acts as CTRL+BREAK
Document Number: Q74348 Publ Date: 19-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
A Visual Basic program will break at run time under the following
simultaneous conditions:
1. You run the program in the Visual Basic development environment.
2. The Visual Basic menu bar has the focus.
3. You press F5.
The program will break when the F5 key is pressed and the Immediate
Window will get the focus. This is not a problem with Visual Basic,
but rather a design feature.
This information only applies to an application run in the Visual
Basic development environment, not as an .EXE program.
This information applies to Visual Basic programming system version
1.0 for Windows
More Information:
The F5 key acts as the shortcut key for the Visual Basic Run menu.
Because Start, Continue, and Break all share the same menu item under
the Run menu, F5 acts differently depending upon the state of
execution of a program. It acts as the Run key in the Visual Basic
1.0 environment. It also serves as the Break key once the application
is running and the focus is on the Visual Basic menu bar. After
execution has been "broken" with the break key, the F5 key serves as
the Continue key.
To demonstrate the different modes of the F5 key, do the following:
1. Run Visual Basic.
2. From the File menu, select New Project (ALT, F, N).
3. Press F5 to run the program.
4. Using the mouse, click on the Visual Basic menu bar.
5. Press F5 to break the program. The Immediate window will be given
the focus after you press F5.
6. Press F5 again to continue execution of the program.
Title: VB Syntax Error Appending : Lines to Sub or Function Statement
Document Number: Q74407 Publ Date: 19-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
A syntax error may occur when a Sub or Function statement is followed
by another statement on the same line, even when separated by a colon
(:).
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
More Information:
To illustrate the problem, type the following code onto a single line
within a Code window:
Sub Foo() : Print "Hello, World" : End Sub
An "Invalid outside Sub or Function" error occurs when you move the
cursor from this line.
If the Sub procedure Foo() already exists,
Sub Foo()
End Sub
then you can add code after the procedure heading, Sub Foo(), if
separated by a colon, as follows:
Sub Foo() : Print "Hello World"
End Sub
Although it is possible to use more than one statement on the same
line with a procedure heading, Microsoft does not recommend this. A
procedure heading should always be on a line by itself.
Title: "Path Not Found: 'T:'" if Hyphen Precedes Directory Name
Document Number: Q74408 Publ Date: 19-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
The error message "Path not found: 'T:'" will occur if you try to open
a project with a directory name that is preceded with a hyphen (for
example, -TEST) in Microsoft Visual Basic programming system version
1.0 for Windows. The problem is due to the way Windows 3.0 interprets
directories with the Windows API function DlgDirSelect. The following
example reproduces the problem.
Steps to Reproduce Problem
--------------------------
1. Create a temporary directory named -TEST (a hyphen followed by
TEST) in your Visual Basic directory.
2. Start Visual Basic. From the File menu, choose Open Project.
3. You should be able to see the "-TEST" directory in the list box.
Try selecting or clicking on that directory. The error message
"Path not found: 'T:'" will be displayed.
Microsoft has confirmed this to be a problem in the Windows 3.0
operating environment (BUGLIST3.00). We are researching this problem
and will post new information here as it becomes available.
Title: Mouse Pointer Disappears in Code Window if ESC or CTRL+BREAK
Document Number: Q74409 Publ Date: 19-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
In Microsoft Visual Basic, the mouse pointer fails to be displayed if
you press ESC or CTRL+BREAK within the Code window. (The mouse pointer
correctly reappears if you move the mouse.)
Microsoft has confirmed this to be a problem with Microsoft Visual
Basic programming system version 1.0 for Windows. We are researching
this problem and will post new information here as it becomes
available.
More Information:
Steps to Reproduce Problem
--------------------------
1. Start Visual Basic with a New Project.
2. Double-click on the form to bring up the Code window. Notice the
I-beam mouse pointer within the Code window. If you place the
mouse pointer outside of the Code window, you will see the I-beam
change to an arrow.
3. Place the mouse pointer back in the Code window to display the
I-beam pointer. Press either the ESC key or the key combination
CTRL+BREAK. The I-beam mouse pointer will temporarily disappear.
4. The pointer will be redisplayed if you move the mouse.
Title: Saving VB Project Changes Design-Time WindowState Property 1,2
Document Number: Q74446 Publ Date: 22-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
In the Properties list box, setting the WindowState property of a
form to either "1 - Minimized" or "2 - Maximized" at design time
incorrectly displays "0 - Normal" after you run the program. When you
run the application again, your last WindowState setting (1 or 2) is
correctly remembered, even though the Properties list box incorrectly
displays "0 - Normal". However, if you save the project, the value for
the WindowState property (1 or 2) will be forgotten, and will
incorrectly return to "0 - Normal".
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching the
problem and will post new information here as it becomes available.
More Information:
Steps to Reproduce Problem
--------------------------
1. In the Properties list box, change the WindowState property of a
form to "1 - Minimized" or "2 - Maximized".
2. From the Run menu, choose Start.
3. From the Run menu, choose End. Notice that the WindowState property
in the Properties list box incorrectly displays "0 - Normal".
4. When you run the program again, the Form1 will correctly be
minimized (1) or maximized (2), showing that the value for
WindowState is remembered.
5. If you save the project and run again, the value set for the
WindowState property is incorrectly reset to "0 - Normal".
To work around this problem, you can set the WindowState property in
the Form_Load event procedure (instead of setting WindowState in the
Properties list box at design time). If you place the following line
of code in the Form_Load event procedure, the application will always
start up maximized:
WindowState = 2 ' 0=normal window; 1=minimized; 2=maximized
Title: "Unresolved External" Attempting to Use CDK VBDirtyForm()
Document Number: Q74338 Publ Date: 25-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
The VBAPI routine VBDirtyForm() is documented within Visual Basic's
add-on Control Development Kit (CDK) and is defined with the CDK
Header file, VBAPI.H. However, the LINK.EXE error "Unresolved
external" occurs when linking your DLL if you attempt to use this
function, because VBDirtyForm() does not actually exist.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows. Microsoft has confirmed this to be a problem
and will post additional information here as it becomes available.
More Information:
The functionality of VBDirtyForm() can easily be achieved using
VBSetControlProperty() to assign a value to any property that has been
defined with the property flags of PF_fSaveData and/or PF_fSaveMsg.
When a property is assigned a value that was defined with one or both
of the property flags, PF_fSaveData or PF_fSaveMsg, VB.EXE takes care
of writing the property value to disk when the form is saved, and is
made aware of any changes made to any property of any control or the
form itself. Thus, VB.EXE knows to save the form when exiting or
opening a new project.
Title: WINAPI.TXT: Windows API Declarations and Constants for VB
Document Number: Q73694 Publ Date: 29-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
The file WINAPI.TXT supplies declarations for Microsoft Visual Basic
programmers who want to call Windows API routines.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
WINAPI.TXT can be found in the Software/Data Library by searching on
the word BV0447, the Q number of this article, or S13104. BV0447 was
archived using the PKware file-compression utility. After you
decompress BV0447, you will obtain the following two files:
WINAPI.TXT
README.NOW
WINAPI.TXT is provided here in the assumption that you already have a
reference for Windows API calls, such as the documentation provided
with the Microsoft Windows Software Development Kit (SDK).
If you don't have a reference manual for Windows API calls, you can
obtain the Visual Basic add-on kit number 1-55615-413-5, "Microsoft
Windows Programmer's Reference" and Online Resource (which includes
WINAPI.TXT on disk), available at a charge from Microsoft.
More Information:
WINAPI.TXT can be found on CompuServe in the MSLANG forum (GO MSLANG),
as well as in the Microsoft Software Library on CompuServe.
Contents of README.NOW
----------------------
WINAPI.TXT is an ASCII text file containing the functions and
constants in the Microsoft Windows 3.0 API, declared in the format
used by Microsoft Visual Basic.
To use WINAPI.TXT, you must have the book "Microsoft Windows
Programmer's Reference" for Windows version 3.0 (published by
Microsoft Press, 1990), or you must have the reference manuals
provided with the Microsoft Windows SDK.
WINAPI.TXT includes the following:
- External procedure declarations for all the Microsoft Windows API
functions that can be called from Visual Basic.
- Global constant declarations for all the constants used by the
Microsoft Windows API.
- Type declarations for the user-defined types (structures) used by
the Microsoft Windows API.
WINAPI.TXT is too large to be loaded directly into a Visual Basic
module. Attempting to load it directly into Visual Basic will cause an
"Out of Memory" error message.
WINAPI.TXT is also too large for the Notepad editor supplied with
Microsoft Windows, but it can be loaded by Microsoft Write. To use
WINAPI.TXT, load it into an editor (such as Microsoft Write) that can
handle large files. Copy the declarations you want and paste them into
the global module in your Visual Basic application.
Note: Some of the Windows API declarations are very long. Some editors
will wrap these onto a second line, and will copy them as multiple
lines rather than a single line. Declarations in Visual Basic cannot
span lines, so if you paste these as multiple lines, Visual Basic will
report an error. If an error occurs, you can either adjust the margins in
the editor before copying or remove the line break after pasting.
The global module is the recommended place for the declarations that
you copy from the WINAPI.TXT file; however, you can place the external
procedure declarations in the Declarations section of any form or
module. You can also place the constant declarations anywhere in any
module or form code if you remove the Global keyword. Type
declarations must be placed in the global module.
Once you have pasted the declaration for a Windows API routine (as
well as any associated constant and type declarations) into your
application, you can call that routine as you would call any Visual
Basic procedure.
For more information about declaring and calling external procedures,
see Chapter 23, "Extending Visual Basic," in "Microsoft Visual
Basic: Programmer's Guide."
Warning
-------
Visual Basic cannot verify the data you pass to Microsoft Windows API
routines. Calling a Microsoft Windows API routine with an invalid
argument can result in unpredictable behavior: your application,
Visual Basic, or Windows may crash or hang. When experimenting with
Windows API routines, save your work often.
Title: "Overflow" Printing Too Large a String to Form or Printer
Document Number: Q74517 Publ Date: 29-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
An "Overflow" error message may occur when you print a long string in
Microsoft Visual Basic.
When a character is printed using the Print method, the CurrentX and
CurrentY coordinates are also updated for the object being printed to.
If the string being printed is long enough to cause the value of the
CurrentX property to exceed 32,767 twips, an "Overflow" error will
occur. This behavior is by design.
"Overflow" can be caused by printing a single long string or by
repeatedly printing shorter strings that are appended onto the end of
the last string (using the Visual Basic semicolon (;) operator).
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
Steps to Reproduce Problem
--------------------------
1. Start Visual Basic or choose New Project from the File menu.
2. Place a label control on Form1.
3. Add the following code to the Form_Click event:
Sub Form_Click()
For index% = 1 to 1000
Print "A";
Label1.Caption = Str$(CurrentX)
Next
End Sub
4. From the Run menu, choose Start.
5. Click on Form1.
An "Overflow" error will occur. You can examine the label caption to
see that the value of Form1.CurrentX plus the TextWidth of "A"
exceeded 32767 at the time of the error.
Title: No Beep when You Click on Form while Menu Design Window Is Up
Document Number: Q74518 Publ Date: 29-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
The Menu Design window, used to create pull-down menus for your Visual
Basic form(s), is a modal dialog box. Because the Menu Design window
is a modal dialog box, clicking on any other Visual Basic window when
the Menu Design window is visible should fail to transfer the focus
and should generate a beep to notify you that you cannot act outside
the dialog box.
However, clicking on the Visual Basic form for which the Menu design
window is opened does not generate a beep. All other Visual Basic
windows, such as the ToolBox, Color Palette, Project Window, and main
Visual Basic menu bar all respond with a beep when the Menu Design
window is active. Focus is maintained by the Menu Design window in
both cases.
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
Title: Control Overlaid by Another Control Fails to Refresh if Moved
Document Number: Q74519 Publ Date: 29-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Visual Basic does not support overlapping controls. Having overlapping
controls can result in portions of a control not refreshing correctly.
If controls are moved over each other, then one or both of the
controls may not correctly refresh even when the controls are moved
apart. This is known to happen when controls are resized at run time
using the Move method or by changing the Height and Width properties
as a result of a Form_Resize event. Because controls must be resized
one at a time, it is possible that one control will briefly overlap
another control during the resize process at run time. The control
that was briefly overlapped may not refresh properly. An example of
this behavior is given further below.
This behavior can be improved by performing the Refresh method
(CtrlName.Refresh) on every overlapping control at run time, after an
overlapped control has been moved or after a form that contains
overlapping controls has been resized.
This is not a problem with Visual Basic, but the nature of overlapping
controls under Visual Basic. This behavior occurs at run time in the
Visual Basic development environment or as an .EXE program.
This information applies to the Visual Basic programming system
version 1.0 for Windows.
More Information:
For more information about Visual Basic and overlapping controls,
query in this knowledge base on the following words:
overlapping and controls and Visual and Basic
Steps to Reproduce Problem
--------------------------
1. From the File menu, choose New Project (ALT, F, P).
2. Add a picture control (Picture1) to the default form (Form1).
3. Add a command button (Command1) to Form1.
4. Add a vertical scroll bar (VScroll1) to Form1.
5. Using the mouse, double-click on Form1 to bring up the code
window.
6. Within the Resize event procedure of Form1, add the following code:
Sub Form_Resize ()
Picture1.Move 0, 0, ScaleWidth - VScroll1.Width, _
ScaleHeight - Command1.Height
VScroll1.Move ScaleWidth - VScroll1.Width, 0, _
VScroll1.Width, ScaleHeight - Command1.Height
Command1.Move 0, ScaleHeight - Command1.Height, _
ScaleWidth, Command1.Height
End Sub
Note: The underscores (_) in the above code example indicate that
the line should be concatenated with the next line in the Visual Basic
environment (VB.EXE).
7. Run the program.
8. Using the mouse, resize the form by extending the bottom or right
sides. When the bottom edge of the form is extended, the command
button (Command1) will not refresh. When the right edge of Form1
is extended, the scroll bar will not refresh. The refresh problems
are caused because Picture1 is expanded and temporarily overlaps
the control. When the control (VScroll1 or Command1) is moved out
of the way, it is not refreshed.
To work around this behavior, use the Refresh method for Picture1,
VScroll1, and Command1 after the controls have be moved. Add the
following statements to Sub Form_Resize (after the Command1.Move
statement) above to overcome the behavior:
Picture1.Refresh
VScroll1.Refresh
Command1.Refresh
Title: Incorrectly Accessing System Menu of Hidden Form
Document Number: Q74564 Publ Date: 29-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
It is possible under certain circumstances to incorrectly access the
system menu of a hidden form in Visual Basic.
Steps to Reproduce Problem
--------------------------
1. Start Visual Basic or choose New Project from the File menu.
2. Set the WindowState property of Form1 to 1 (minimized).
3. Enter the following line of code in the Form_Resize event
procedure of Form1:
If WindowState = 2 Then Hide 'WindowState 2 = maximized
4. From the Run menu, choose Start.
5. Click on the Form1 icon to bring up the system menu for Form1.
6. From the the Form1 system menu, choose Maximize. Form1 will maximize
and then hide.
7. Press ALT+SPACE to activate the Form1 system menu.
A system menu will appear in the upper left corner of the screen, even
though Form1 is hidden.
Microsoft has confirmed this to problem with Microsoft Visual Basic
programming system 1.0 for Windows. We are researching this problem
and will post new information here as it becomes available.
Title: Incomplete Path Causes "Insufficient Disk Space" During Setup
Document Number: Q74646 Publ Date: 29-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
You may receive an "Insufficient disk space on: XXX" error message
when running the Microsoft Visual Basic version 1.0 Setup program if
you have not specified a drive letter in your path to Windows 3.0.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
If you have a partial PATH to the Windows environment (for example,
PATH=\WIN3) in your AUTOEXEC.BAT file, you may need to reset the PATH
to C:\WIN3. After you reset the path, Setup should run correctly.
Title: "Insufficient Disk Space" After Setup Begins to Copy Files
Document Number: Q74648 Publ Date: 29-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
If you receive an "Insufficient disk space" error message when running
Visual Basic's Setup program, it may be caused by using Windows with a
temporary Windows swap file instead of the permanent Windows swap
file.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
Pages 520 through 529 in the "Microsoft Windows User's Guide" version
3.0 manual discuss Windows swap files. Permanent swap files are
contiguous so that your disk does not contain files in fragmented
pieces, which may happen if you are using temporary swap files.
Temporary Windows swap files may grow in size, which may cause the
"Insufficient disk space" error during the execution of Visual Basic's
Setup program. However, permanent Windows swap files will not change
in size, so using permanent Windows swap files may help to avoid the
"Insufficient disk space" error.
Title: EVENTINFO Topic Correction for VB CDK VBAPI.HLP File
Document Number: Q74649 Publ Date: 29-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Below is a correction to the VBAPI.HLP file provided in the Microsoft
Visual Basic Control Development Kit (add-on kit number 046-050-022).
In the VBAPI.HLP file, for the structure topic named EVENTINFO, a
column title is incorrectly labeled "Flag Value," but should instead
be labeled "Field Name."
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
Title: Visual Basic Add-on Kits: CDK, Windows Reference, 360K Disks
Document Number: Q72265 Publ Date: 30-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Microsoft has developed the following add-on kits to help Visual Basic
programming-system users get even more from the product. You may call
Microsoft End User Sales and Service at (800) 426-9400 to order these
kits (except kit no. 5 below). Please note the specific requirements for
the kits:
1. "Microsoft Windows Programmer's Reference" book and Online Resource
This complete reference to the Microsoft Windows API includes the
following:
a. A comprehensive 1152-page reference book for Windows 3.0
(published by Microsoft Press, 1990)
b. Online references to each component of the Windows API in
Windows Help format. Includes both 5.25-inch and 3.5-inch disks.
c. WINAPI.TXT: Function, Type, and Constant declarations in Visual
Basic format for nearly every Windows API function. Note: A
correction for the WINAPI.TXT file dated 5/14/91 is described in
a separate article in this knowledge base. To find that article,
query on the following words: WINAPI.TXT and correction.
d. APIXREF.HLP: Quick reference listing the value of every constant
and the appropriate library for every function.
Kit number: 1-55615-413-5
Price: $49.95 (plus shipping/and handling and applicable sales tax)
2. Microsoft Visual Basic Control Development Kit (CDK)
This kit enables you to develop Visual Basic controls to extend the
Visual Basic Toolbox to meet your specific needs. Custom controls
can be placed on forms and used just like built-in controls. You
determine the appearance and functionality -- including properties
and events -- of each control. Includes both 5.25-inch and 3.5-inch
disks.
Requires: Microsoft Windows Software Development Kit (SDK) (version
3.0 or later) and Microsoft C compiler (version 6.0 or later)
Note: Custom controls are written in C and require extensive
knowledge of the Windows API.
Kit number: 046-050-022
Price: $49.95 (plus shipping/handling and applicable sales tax)
3. Microsoft Windows Help Compiler
The Windows Help system lets you provide online Help to those using
your Visual Basic application. Supports hypertext links and
context-sensitive Help screens, using the Windows Help engine.
Includes both 5.25-inch and 3.5-inch disks. Includes a sample help
file and a sample Visual Basic program (which doubles as an
application to test help files).
Requires: An RTF (rich text formatting) text editor, such as
Microsoft Word for Windows.
Kit number: 046-050-052
Price: $49.95 (plus shipping/handling and applicable sales tax)
4. Visual Basic Low-Density (360K) 5.25-inch Disks
If your hardware cannot accommodate the high-density (1.2 MB)
5.25-inch disks or low-density (720K) 3.5-inch disks included in
the Visual Basic programming system package, you may order
low-density (360K) 5.25-inch disks for the program.
Kit number: 046-050-004
Price: free (pay only shipping/handling)
The following kit for Microsoft SQL Server developers includes a copy
of Visual Basic (contact Microsoft On-line Sales at 1 (800) 443-4672
for more information):
5. Windows-Based Visual Basic Library and Software Development Kit
(SDK) for Microsoft SQL Server
Contains SQL programming libraries, a preliminary documentation
set, and a copy of Visual Basic programming system. Allows Visual
Basic programmers to quickly develop rich Microsoft Windows graphical
client-server applications for Microsoft SQL Server. Developers can
also use Visual Basic Library for SQL Server with the Database
Gateway(TM) from Micro Decisionware, Boulder, Colo., to build
graphical applications that tap DB2 (TM) and other IBM mainframe
data sources.
(Microsoft SQL Server is an intelligent client-server relational
database-management system (RDBMS) for PC networks. Providing
capabilities previously the exclusive domain of mainframe and
minicomputer systems, Microsoft SQL Server brings high-end
performance, security, and data integrity to local area networks,
allowing data to be shared safely among many applications and
users. Microsoft SQL Server is supported by popular networks such
as Microsoft LAN Manager, Novell NetWare, and IBM LAN Server.)
Visual Basic Library for SQL Server is available as a Software
Development Kit. It is available directly from Microsoft for $495.
Contact Microsoft On-line Sales at 1 (800) 443-4672 for sales and
support information. For pricing and availability outside the U.S.,
please contact your local Microsoft subsidiary.
The above information is accurate as of July 29, 1991, and is subject
to change.
Title: No Title for Project Window After Loading from Command Line
Document Number: Q74677 Publ Date: 30-JUL-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
A naming problem can occur when you invoke the VB.EXE (Visual Basic)
environment with a project from the Windows command line with a .FRM,
.BAS, or a .VBX filename extension. If you start a project with any of
these extensions, you will see an untitled Project Window displayed,
and if you make any changes to that Form and try to exit Visual Basic,
Visual Basic will correctly prompt you to save the changes to that
Form. However, if you first select New Form to add to the Project, you
will be prompted to save the forms and to save the project under a
blank project name. The project name is incorrectly blank and should
instead reflect the last project name.
Microsoft has confirmed this to be a problem with Microsoft Visual
Basic programming system version 1.0 for Windows. We are researching
this problem and will post new information here as it becomes
available.
More Information:
Steps to Reproduce Problem
--------------------------
1. Start Visual Basic or choose New Project from the File menu.
2. From the File menu, choose Save Project As. Save the form with the
name Test1.FRM and the project with the name Test1.MAK.
3. From the Visual Basic File menu, choose Exit.
4. From the Windows Program Manager File menu, choose Run. Enter the
following path:
C:\VB\Test1.FRM
5. Visual Basic will start with an untitled Project Window that
contains the files Global.BAS and TEST1.FRM.
6. From the Visual Basic Run menu, choose Exit. Note that if you make
any changes to Test1.FRM and try to exit Visual Basic, the message
"Save changes to 'TEST1.FRM'?" will be displayed. If you choose Yes,
the changes to the form will be saved. If you choose to add another
form from the File menu with the New Form command, you will be asked
to to save the changes to each Form followed by the message "Save
changes to '?'" when you exit Visual Basic. This is a problem unless
you remember the Project name Test1.MAK. If you remember the filename,
then the message "Replace existing 'C:\VB\TEST1.MAK'?" will be
displayed and the new form or forms will be added to the project under
the old project name.
A workaround is to choose the Run command from the Windows Program
Manager File menu with the following Path:
C:\VB\Test1.MAK
Visual Basic should now start with the correctly titled Project Window
named TEST1.MAK.
Title: Documentation Errors in First Printing of VB CDK Guide
Document Number: Q74676 Publ Date: 2-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Below is a list of documentation errors in the first printing of the
"Microsoft Visual Basic: Control Development Guide" shipped with the
Visual Basic Control Development Kit (CDK).
The documentation errors listed below may not apply to later printings
of the "Microsoft Visual Basic: Control Development Guide."
Many of the errors were corrected in the CDK Help file before
shipping.
The CDK is an add-on to the Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
Corrections to the "Microsoft Visual Basic: Control Development Guide"
----------------------------------------------------------------------
(page 79) Middle of the page:
"...fourth field in the EVENTINFO structure..." should read
"...fourth field in the PROPINFO structure..."
Code at bottom of page:
"OFFSETIN(MYCTL, Language)," should read
"OFFSETIN(MYCTL, enumLanguage),"
(page 112) VBXPixelsToTwips, VBYPixelsToTwips:
Return data type is listed in Syntax as SHORT; it should be LONG.
"...in logical twips into a measurement in pixels..." should read
"...in logical pixels into a measurement in twips..."
In the chart, Type should list as SHORT.
(page 136) In the table, the incorrect heading "Flag Value" should be
changed to "Field Name".
Title: Closed Split Window Incorrectly Allows Text Entry
Document Number: Q74731 Publ Date: 2-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
You can cause Microsoft Visual Basic to set the input focus to an
invisible "view" of a split code window. Input is still accepted when
the focus is set to the invisible portion of the code window, but will
not be visible to the user. This is incorrect behavior, because
closing a split window should shift focus to the first window.
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
More Information:
Note that the "splitter bar" (the horizontal border just above the
editing area and just above the vertical scroll bar) allows you to
split the code window into two parts, which allows you to view two
different sections of code at once.
Steps to Reproduce Problem
--------------------------
1. Start Visual Basic or choose New Project from Visual Basic's
File menu.
2. Double-click on Form1 to bring up a code window.
3. Drag down the code window splitter bar to the middle of the code
window, splitting the code window into two views.
4. Click in the upper view of the code window to place the text
insertion point there.
5. Select the code window splitter bar and drag it upwards to close
the upper view in the code window.
6. Type "Sub foo" (without the quotation marks) and press ENTER. No
text will appear in the code window, because the focus is set to the
invisible half of the window. However, the contents of the "Proc"
drop-down combo box will change to "Foo," indicating that Sub Foo has
been created.
7. Click on the code window splitter bar again and pull the splitter
bar back to the center of the code window. The text insertion point
will appear in the upper view of the code window, and the current
procedure for the upper view will be Sub Foo.
Title: Example of Client/Server DDE Between Visual Basic Applications
Document Number: Q74861 Publ Date: 2-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
This article outlines the steps necessary to initiate dynamic data
exchange (DDE) between a Microsoft Visual Basic client application and
a Visual Basic server application.
This article demonstrates how to:
1. Create a Visual Basic application to function as a server.
2. Create a Visual Basic application to function as a client.
3. Initiate a cold DDE link (information updated upon request from the
client) between the client application and the server application.
4. Use LinkRequest to update information in the client application
from information in the server application.
5. Initiate a hot DDE link (information updated automatically from
server to client) between the client application and the server
application.
6. Use LinkPoke to send information from the client application to the
server application.
7. Change the LinkMode property between hot and cold.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Microsoft Windows.
More Information:
A client application sends commands through DDE to the server
application to establish a link. Through DDE, the server provides data
to the client at the request of the client or accepts information at
the request of the client.
Example
-------
The steps below are an example of how to establish a DDE conversation
between two Visual Basic applications.
First, create the server application in Visual Basic:
1. Start Visual Basic, and Form1 will be created by default.
2. Change the Caption property of Form1 to "Server".
3. Put a Text Box (Text1) on Form1.
4. Save the form and project with the name SERVER.
5. From the File menu, choose Make EXE File. In the Make EXE File
dialog box, choose OK to accept SERVER.EXE as the name of the EXE
file.
Second, create the client application in Visual Basic:
1. From the File menu, choose New Project. Form1 will be created by
default.
2. Change the Caption property of Form1 to "Client".
3. Create the following controls with the following properties on
Form1:
Default Name Caption CtlName
------------ ------- -------
Text1 (Not applicable) Text1
Option1 Cold Link ColdLink
Option2 Hot Link HotLink
Command1 Poke Poke
Command2 Request Request
4. Add the following code to the General Declaration section of Form1:
Const TRUE = -1
Const FALSE = 0
Const HOT = 1
Const COLD = 2
Const NONE = 0
5. Add the following code to the Load event procedure of Form1:
Sub Form_Load ()
'This procedure will start the VB server application that was
'created earlier
z% = Shell("C:\VB\SERVER", 1)
z% = DoEvents() 'Causes Windows to finish
'processing the Shell command.
Text1.LinkMode = NONE 'Clears DDE link if it already exists.
Text1.LinkTopic = "Server]Form1" 'Sets up link with VB server.
Text1.LinkItem = "Text1" 'Set link to text box on server.
Text1.LinkMode = COLD 'Establish a cold DDE link.
ColdLink.Value = TRUE 'Sets appropriate option button.
End Sub
6. Add the following code to the Click event procedure of ColdLink:
Sub ColdLink_Click ()
Request.Visible = TRUE 'Make request button valid.
Text1.LinkMode = NONE 'Clear DDE Link.
Text1.LinkMode = COLD 'Reestablish new LinkMode.
End Sub
7. Add the following code to the Clink event procedure of HotLink:
Sub HotLink_Click ()
Request.Visible = FALSE 'No need for button with hot link.
Text1.LinkMode = NONE 'Clear DDE Link.
Text1.LinkMode = HOT 'Reestablish new LinkMode.
End Sub
8. Add the following code to the Click event procedure of Request:
Sub Request_Click ()
'With a cold DDE link, this button will be visible, and when
'selected it will request an update of information from the server
'application to the client application.
Text1.LinkRequest
End Sub
9. Add the following code to the Click event procedure of Poke:
Sub Poke_Click ()
'With any DDE link, this button will be visible, and when
'it selected, will poke information from the client application
'into the server application.
Text1.LinkPoke
End Sub
You can now run the Visual Basic client application from the VB.EXE
environment (skip to step 4 below) or you can save the application and
create an .EXE file and run that from Windows (continue to step 1
below).
1. From the File menu, choose Save and save the form and project with
the name CLIENT.
2. From the File menu, choose Make EXE File with the name CLIENT.EXE.
3. Exit the Visual Basic environment (VB.EXE).
4. Run the application (from Windows if an .EXE file, or from the Run
menu if from the VB.EXE environment.)
5. Form1 of the client application will load and the server
application will automatically start.
You can now experiment with DDE between Visual Basic applications:
1. Try typing some text into the server's text box and then click the
Update button. The text appears in the client's text box.
2. Click the Hot Link button and then type some more text into the
server's text box. The text is automatically updated in the
client's text box.
3. Type some text into the client's text box and click the Poke
button. The text is sent to the server's text box.
You can also establish DDE between applications at design time, as
described on page 356 of the "Microsoft Visual Basic: Programmer's
Guide" version 1.0 manual.
For additional information on dynamic data exchange (DDE) between
Visual Basic 1.0 and other Windows applications, query on the
following words:
DDE and Visual Basic
Title: DDE Example Between Visual Basic and Word for Windows
Document Number: Q74862 Publ Date: 2-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
This article outlines the steps necessary to initiate dynamic data
exchange (DDE) between a Microsoft Visual Basic application and a
Microsoft Word for Windows (WINWORD.EXE) document at run time.
This article demonstrates how to:
1. Prepare a Word for Windows document for active DDE.
2. Initiate a cold DDE link (information updated upon request from
the client) between the Visual Basic application (the client) and
the document loaded into Word for Windows (the server).
3. Use LinkRequest to update information in the Visual Basic client
based on information contained in the Word for Windows server.
4. Initiate a hot DDE link (information updated automatically from
server to client) between the Visual Basic client and the Word for
Windows server.
5. Use LinkPoke to send information from the Visual Basic client to
the Word for Windows server.
6. Change the LinkMode property between hot and cold.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Microsoft Windows.
More Information:
A client application sends commands through DDE to the server
application to establish a link. Through DDE, the server provides data
to the client at the request of the client or accepts information at
the request of the client.
Example
-------
The steps below are an example of how to establish a DDE conversation
between a Visual Basic application and a document loaded into Word for
Windows (WINWORD.EXE).
First, create the server document in Word for Windows:
1. Start Word for Windows. "Document1" will be created by default.
2. From the Window menu, choose Arrange All. This unmaximizes the
document if it was maximized. Note that the title at the top of the
WINWORD.EXE main title bar is now "Microsoft Word" and NOT
"Microsoft Word - Document1".
3. Press SHIFT+END to select the document.
4. From the Insert menu, choose Bookmark. Under Bookmark Name, type
"DDE_Link" (without quotation marks). Press ENTER. This sets a
bookmark for the entire document. This bookmark will function as
the LinkItem in the DDE conversation.
5. From the File menu, choose Save As, and save the document with the
name SERVER.DOC.
6. Exit Word for Windows. For this particular example to function
properly, WINWORD.EXE must not be loaded and running.
Second, create the client application in Visual Basic:
1. Start Visual Basic. Form1 will be created by default.
2. Create the following controls with the following properties on
Form1:
Default Name Caption CtlName
------------ ------- -------
Text1 (Not applicable) Text1
Option1 Cold Link ColdLink
Option2 Hot Link HotLink
Command1 Poke Poke
Command2 Request Request
3. Add the following code to the General Declaration section of Form1:
Const TRUE = -1
Const FALSE = 0
Const HOT = 1
Const COLD = 2
Const NONE = 0
4. Add the following code to the Load event procedure of Form1:
Sub Form_Load ()
'This procedure will start WINWORD.EXE, load the document that was
'created earlier and prepared for DDE by creating a bookmark to
'the whole document. This bookmark is necessary because it
'functions as the LinkItem for the server in the DDE conversation.
z% = Shell("C:\WinWord\WinWord C:\WinWord\Server.Doc",1)
z% = DoEvents () 'Process Windows events. This ensures
'that WinWord will be executed before
'any attempt is made to perform DDE
'with it.
Text1.LinkMode = NONE 'Clears DDE link if it already exists.

Text1.LinkTopic = "WinWord]\WinWord\Server" 'Sets up link with
'WINWORD.EXE.
Text1.LinkItem = "DDE_Link" 'Set link to bookmark on document.
Text1.LinkMode = COLD 'Establish a cold DDE link.
ColdLink.Value = TRUE
End Sub
5. Add the following code to the Click event procedure of the Cold
Link button:
Sub ColdLink_Click ()
Request.Visible = TRUE 'Make request button valid.
Text1.LinkMode = NONE 'Clear DDE Link.
Text1.LinkMode = COLD 'Reestablish new LinkMode.
End Sub
6. Add the following code to the Click event procedure of the Hot
Link button:
Sub HotLink_Click ()
Request.Visible = FALSE 'No need for button with hot link.
Text1.LinkMode = NONE 'Clear DDE Link.
Text1.LinkMode = HOT 'Reestablish new LinkMode.
End Sub
7. Add the following code to the Click event procedure of the Request
button:
Sub Request_Click ()
'With a cold DDE link this button will be visible, and clicking
'this button will request an update of information from the server
'application to the client application.
Text1.LinkRequest
End Sub
8. Add the following code to the Click event procedure of the Poke
button:
Sub Poke_Click ()
'With any DDE link, this button will be visible, and clicking
'this button will poke information from the client application
'into the server application.
Text1.LinkPoke
End Sub
You can now run the Visual Basic client application from the Visual
Basic VB.EXE environment (skip to step 4 below) or you can save the
application and create an EXE file and run that from Windows (continue
to step 1 below).
1. From the File menu, choose Save and save the form and project with
the name CLIENT.
2. From the File menu, choose Make EXE File with the name CLIENT.EXE.
3. Exit the Visual Basic environment (VB.EXE).
4. Run the application (from Windows if an .EXE file or from the Run
menu if from the Visual Basic environment.)
Form1 of the Visual Basic client application will be loaded, and
Word for Windows will automatically be started with the document
SERVER.DOC loaded.
5. Make sure that the main title bar in WINWORD.EXE reads "Microsoft
Word", NOT "Microsoft Word - SERVER.DOC". If the title bar is not
correct, choose Arrange All from the Window menu.
You can now experiment with DDE between Visual Basic and Word
for Windows:
1. Try typing some text into the document in Word for Windows, and
then click the Request button. The text appears in the text box.
2. Click Hot Link and then type some more text into the document in
Word for Windows. The text is automatically updated in the Visual
Basic text box.
3. Type some text in the text box in the Visual Basic application and
click the Poke button. The text is sent to the document in Word for
Windows.
Note that if in the WINWORD.EXE document, you delete the total
contents of the bookmark, the bookmark will also be deleted. Any
further attempt to perform DDE with this WINWORD.EXE session after the
bookmark has been deleted gives the following error message:
Foreign application won't perform DDE method or operation.
If this happens, you must recreate the bookmark in the document in
Word for Windows before performing any further DDE operations.
You can also establish DDE between applications at design time, as
described on page 356 of the "Microsoft Visual Basic: Programmer's
Guide" version 1.0 manual.
For additional information on dynamic data exchange (DDE) between
Visual Basic 1.0 and other Windows applications, query on the
following words:
DDE and Visual Basic
Title: Access Key Causes Different Event Order than Clicking
Document Number: Q74905 Publ Date: 6-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
In Visual Basic, events may be generated in a different order if you
choose a control (such as a button, a check box, or an option box)
using an access key rather than with the mouse. The events that occur
in a different order are Click, LostFocus, and GotFocus. The differing
order of events is by design and is not the result of a problem with
Visual Basic.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
You can create an access key at design time by changing the
Caption property of a control to include an ampersand (&). The access
key is the character after the ampersand, and at run time you press
ALT+character to choose the control. (See page 120 of the "Microsoft
Visual Basic: Programmer's Guide" version 1.0. manual.)
When you press an access key (ALT+character) to choose a control, the
Click event is generated before the LostFocus and GotFocus event;
however, when you choose a control by clicking the mouse, the
LostFocus and GotFocus events are generated before the Click event.
The example below shows this different order of events. The example
uses command buttons, but also applies to Check and Option boxes:
1. Open a new form and create two command buttons.
2. Enter the code as shown further below.
3. Change the Caption property of Command2 to "Command&2"
4. Run the program.
5. a. When Command1 has the focus and you click on Command2, the
following events are generated in the following order:
Command1_LostFocus
Command2_GotFocus
Command2_Click
b. When Command1 has the focus and you press the access key, ALT+2,
the following events are generated in the following order:
Command2_Click
Command1_LostFocus
Command2_GetFocus
Sample Code:
-----------
Sub Command1_Click ()
Print "Command1_click"
End Sub
Sub Command1_LostFocus ()
Print "Command1_lostfocus"
End Sub
Sub Command1_GotFocus ()
Print "Command1_gotfocus"
End Sub
Sub Command2_Click ()
Print "Command2_click"
End Sub
Sub Command2_LostFocus ()
Print "Command2_lostfocus"
End Sub
Sub Command2_GotFocus ()
Print "Command2_gotfocus"
End Sub
Title: Carriage Return+Linefeed to Wrap Lines in Text Box Control
Document Number: Q74906 Publ Date: 6-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Using the carriage return character, Chr$(13), alone to create a line
wrap to the next line in a Visual Basic text box control will cause
the character following the carriage return to be removed from a
multiline text box. To correctly wrap to the next line, you must
instead use both a carriage return and a linefeed, Chr$(10). This
requirement is by design.
This information applies to Microsoft Visual Basic programming system

version 1.0 for Windows.
More Information:
The correct method to create a line wrap is to use a carriage return
character followed by a linefeed character, Chr$(13) + Chr$(10). The
Windows text box expects to find this sequence and assumes that the
character following the carriage return is a linefeed, thus removing
the following character as if it were a linefeed.
The following steps show the results of using just the carriage
return, and the results of using both carriage return and linefeed
characters in a text box.
1. In a new project, click on the text box icon from the Toolbox
(second tool down in the right column).
2. Click anywhere on the form and drag diagonally to create a text box
large enough to hold more then one line of text.
3. From the Properties bar (below the main menu) scroll down to
Multiline, then choose the Settings box for that Multiline property
(also on the Properties bar below the menu) and choose True. The
text box can now accommodate several lines of text.
4. Double-click anywhere in the form outside of the text box to bring
up the Form_click code window (or use the F7 function key).
5. On the line below Sub Form_click (), type the following:
Text1.text = "Hello" + Chr$(13) + "World"
6. Press F5 to run the newly created application, then click
anywhere in the form outside the text box. The following text
will appear:
Hello
orld
Note that the W of "World" is missing.
7. To obtain the desired result, you must add a linefeed following the
carriage return character, as follows:
Text1.text = "Hello" + Chr$(13) + Chr$ (10) + "World"
This will now display as expected:
Hello
World
Title: How VB Can Determine if a Specific Windows Program Is Running
Document Number: Q72918 Publ Date: 13-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
To determine if a specific program is running, call the Windows API
function FindWindow. FindWindow returns the handle of the window whose
class is given by the "lpClassname" parameter and whose window name,
or caption, is given by the "lpCaption" parameter. If the returned
value is zero, then the application is not running.
This information applies to Microsoft Visual Basic Programming System
version 1.0 for Windows.
More Information:
By calling FindWindow with a combination of a specific program's class
name and/or the title-bar caption, your program can determine whether
that specific program is running.
When an application is started from the Program Manager, it registers
the class name of the form. The window class provides information
about the name, attributes, and resources required by your form. All
Visual Basic forms have a class name of "ThunderForm". You can
determine the class name of an application by using SPY.EXE that comes
with the Microsoft Windows 3.0 Software Development Kit (SDK).
If the window has a caption bar title, you can also use the title to
locate the instance of the running application. This caption text is
valid even when the application is minimized to an icon.
Because another instance of your Visual Basic program will have the same
class name and may have the same title bar caption, you must use
Dynamic Data Exchange (DDE) to determine if another instance of your
Visual Basic program is running. (This DDE technique is not shown in
this article).
The following example shows three ways to determine if the Windows 3.0
Calculator is running. To create the program, do the following:
1. Create a form.
2. Declare the Windows 3.0 API function FindWindow in the Global-
Declarations section of the code window. The variables are declared
as "Any" because you can pass either a pointer to a string, or a NULL
value. You as a programmer are responsible for passing the correct
variable type. Note that the Declare statement should be entered on
just one line:
Declare Function FindWindow% Lib "user" (ByVal lpClassName As Any,
ByVal lpCaption As Any)
3. Add the following code to the form's Click event. This example
demonstrates how you can find the instance of the application with a
combination of the class name and/or the window's caption. In this
example, the application will find an instance of the Windows 3.0
calculator (CALC.EXE).
Sub Form_Click ()
Const NULL = 0&
lpClassName$ = "SciCalc"
lpCaption$ = "Calculator"
Print "Handle = ";FindWindow(lpClassName$, NULL)
Print "Handle = ":FindWindow(NULL, lpCaption$)
Print "Handle = ";FindWindow(lpClassName$,lpCaption$)
End Sub
4. Run this program with CALC.EXE running and without CALC.EXE
running. If CALC.EXE is running, your application will print an
arbitrary handle. If CALC.EXE is not running, your application will
print the number zero as a handle.
Below are some class names of applications that are shipped with
Windows 3.0:
Class Name Application
----------- -----------
SciCalc CALC.EXE
CalWndMain CALENDAR.EXE
Cardfile CARDFILE.EXE
Clipboard CLIPBOARD.EXE
Clock CLOCK.EXE
CtlPanelClass CONTROL.EXE
Session MS-DOS.EXE
Notepad NOTE.EXE
pbParent PBRUSH.EXE
Pif PIFEDIT.EXE
PrintManager PRINTMAN.EXE
Recorder RECORDER.EXE
Reversi REVERSI.EXE
#32770 SETUP.EXE
Solitaire SOL.EXE
Terminal TERMINAL.EXE
WFS_Frame WINFILE.EXE
MW_WINHELP WINHELP.EXE
#32770 WINVER.EXE
MSWRITE_MENU WRITE.EXE
Reference(s):
"Peter Norton's Windows 3.0 Power Programming Techniques," by Peter
Norton and Paul Yao (published by Bantam Computer Books, 1990).
Title: Option Button with Access Key Gives UAE if Unload Is Invoked
Document Number: Q74982 Publ Date: 13-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
If an option button containing an Unload statement in its Click event
procedure is selected using the keyboard (an access key, the cursor
keys, or the TAB key), the application terminates with a Windows
Unrecoverable Application Error (UAE). Using the mouse to select
the option button causes the Unload statement to execute correctly and
does not generate a UAE.
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
More Information:
Steps to Reproduce Problem
--------------------------
1. Run Visual Basic or choose New Project from the File menu (ALT, F,
N). Form1 will be created by default.
2. Place any control on Form1.
3. Place an option button (Option1) on Form1.
4. Assign an access key to Option1 by entering "&UAE" (without the
quotation marks) for the Caption property of Option1. This will
cause the letter U to become the access key for Option1.
5. Add the following code to the Option1_Click event procedure:
Sub Option1_Click ()
Unload Form1
End Sub
6. Run the program (F5).
7. Use the access key (ALT+U), the cursor keys, or the TAB key to
select the option button. When the option button is selected in
this manner, a UAE will be generated.
When you select the option button with the mouse, no UAE will occur.
The UAE only occurs when the Click event is caused from the keyboard.
Title: "Visual Basic 1.0 Setup by Batch File" Appnote Available
Document Number: Q75370 Publ Date: 20-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
In rare cases, certain hardware configurations may not work properly
with the SETUP.EXE utility shipped with Microsoft Visual Basic
programming system version 1.0 for Windows.
As an alternative installation method for Visual Basic 1.0, you can
use the application note titled "Visual Basic 1.0 Setup by Batch File"
(BV0446). To obtain application notes, call Microsoft Product Support
Services at (206) 454-2030. Please specify whether you want a 3.5-inch
(720K) or 5.25-inch (1.2 MB) disk (no other disk format is available).
More Information:
Microsoft can only distribute this application note to registered
owners of Visual Basic because it contains uncompressed copies of
Visual Basic's Icon Library files. Thus, this application note is not
available on online electronic services; it is only available directly
from Microsoft.
This application note includes the following files and subdirectories
on disk:
README.NOW VBSETUP.BAT VBSETUP1.BAT DECOMP.EXE
VBSETUP.BAT must be run from DOS and from the drive in which you
inserted the disk. For example, typing the following from the drive C
DOS prompt won't work:
a:vbsetup
Instead, you must make drive A (or the drive in which you inserted the
disk) the active drive before running VBSETUP.BAT. For example, type
"A:" (without the quotation marks) at the drive C DOS prompt and then
type "VBSETUP" at the drive A DOS prompt.
Note: When you run VBSETUP as shown above (with no arguments), further
usage instructions will be displayed on the screen.
The Icon Library shipped with Visual Basic is contained on the
enclosed disk in uncompressed format, and will be copied to your
destination directory by VBSETUP. This disk (and the included Icon
Library) may only be distributed to registered owners of Microsoft
Visual Basic. VBSETUP.BAT will only work with 5.25-inch 1.2 MB disks,
or with 3.5-inch 720K disks. VBSETUP.BAT will not work with 5.25-inch
360K disks.
Title: Determining Whether TAB or Mouse Gave a VB Control the Focus
Document Number: Q75411 Publ Date: 20-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
You can determine whether a Visual Basic control received the focus
from a mouse click or a TAB keystroke by calling the Windows API
function GetKeyState in the control's GotFocus event procedure. By
using GetKeyState to check if the TAB key is down, you can determine
if the user tabbed to the control; if the TAB key was not used (and
the control does not have an access key), the user must have clicked
on the control with the mouse to set the focus.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
The GetKeyState Windows API function takes an integer parameter
containing the virtual key code for the desired key states.
GetKeyState returns an integer. If the return value is negative, the
key has been pressed.
The following is a code example. To use this example, start with a new
project in Visual Basic. Add a text box and a command button to Form1.
Enter the following code in the project's GLOBAL.BAS module:
'Global Module
Declare Function GetKeyState% Lib "User" (ByVal nVirtKey%)
Global Const VK_TAB = 9
Add the following code to the GotFocus event procedure for the Text1
text box control:
Sub Text1_GotFocus()
If GetKeyState(VK_TAB) < 0 Then
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Else
Text1.SelLength = 0
End If
End Sub
Run the program. If you use the TAB key to move the focus from the
command button to the text box, you should see the text in the text
box selected. If you change the focus to the text box by clicking on
it with the mouse, the text will not be selected.
If the control has an access key (assigned by using an ampersand [&|
in the control's caption property), then you may also want to check
the state of the virtual ALT key using GetKeyState to see if the user
changed the focus using the access key. The virtual key code for ALT,
actually known as VK_MENU, is 12.
Title: Setup "Illegal Function Call" if Manually Delete Existing File
Document Number: Q75412 Publ Date: 20-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
If the Microsoft Visual Basic Setup program detects an existing copy
of Visual Basic already on the disk during installation, Setup will
ask whether or not you want to "Overwrite existing files?". At this
point, if you manually delete the existing files using a separate
process in Windows and then attempt to continue with the Setup, Setup
will give an "Illegal function call" error message and end without
installing Visual Basic.
Microsoft has confirmed this to be a problem with the Microsoft Visual
Basic programming system version 1.0 for Windows. We are researching
this problem and will post new information here as it becomes
available.
To work around the problem, let Setup overwrite the existing files.
More Information:
Steps to Reproduce Problem
--------------------------
1. Have an installation of Visual Basic in the \VB subdirectory of
your hard disk.
2. Run the Visual Basic SETUP.EXE program.
3. When the subdirectory path to install Visual Basic is displayed,
make sure it points to the VB subdirectory where the files already
exist. Click on Continue.
4. Do not reply to the following message:
"A previous installation of Visual Basic has been found in this
directory. Overwrite existing files?"
5. Go to the File Manager in Windows and delete the existing Visual
Basic files.
6. Return to the Visual Basic Setup and click Yes in reply to the
message.
When you reply OK to the "Illegal function call" message that appears,
Setup ends without installing Visual Basic. To work around this
behavior when Visual Basic files already exist prior to installation,
either delete those files before starting Setup or let Setup overwrite
the existing files.
Title: Corrections for Errors in Visual Basic Version 1.0 Manuals
Document Number: Q73655 Publ Date: 21-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Below are corrections for documentation errors in the manuals shipped
with Microsoft Visual Basic version 1.0 for Windows.
This master list of corrections includes and adds to the correction
list found in sections 2 and 3 of the README.TXT file shipped with
Visual Basic 1.0. Please use the article below as your master list for
making corrections to the Visual Basic manuals.
More Information:
Microsoft Visual Basic includes the following two manuals:
- "Microsoft Visual Basic: Programmer's Guide"
- "Microsoft Visual Basic: Language Reference"
In both manuals, all references to OS/2 and Presentation Manager (PM)
are misprints, and should be ignored.
Corrections to the "Microsoft Visual Basic: Programmer's Guide"
---------------------------------------------------------------
(page 61) "To set the Caption property:" #2, last line:
"...you can skip Step 4 and proceed to Step 5." should read
"...you can skip Step 3 and proceed to Step 4."
(page 97) First line:
"...calls to the LogB procedure..." should read
"...calls to the LogF procedure..."
(page 106) Code at bottom of page should read:
x = Shell("\winword\winword.exe c:\winword\plan.doc", 1)
and
y = Shell("\winproj\winproj.exe c:\winproj\schedule.wpr", 1)
(page 117) Table at bottom of page, last two lines should be:
Caption CtlName Indented Index
- SepBar Once
AppName Once 0
(Note that the README.TXT file incorrectly says to use 1 as
the index value for AppName above; 0 is the correct value.)
The following text should read:
"Turn off the Visible property for AppName by toggling the
Visible check box. The SepBar control has its caption set to a
hyphen (-), which causes Visual Basic to display a separator
bar."
(page 118) Second paragraph, delete the following:
"Therefore, you cannot delete the...of Appname."
Add the following line of code just above the End Sub for the
AddApp_Click procedure:
AppName(LMenu).Visible = -1
(page 129) Last paragraph, first line:
"...tabbing to the button and..." should read
"...tabbing to the option button group, using the arrow keys,
and..."
(page 146) Top:
"MsgBox msg$[,type%[,type%[,title$||" should read
"MsgBox msg$[,type%[,title$||"
(page 153) Lines 8 through 14:
All references to CurrentX should be CurrentY and vice versa.
(page 170) Code at bottom of page:
Text1(I).Text = "Text1(" + Format(I) + ")" should read
Text1(I).Text = "Text1(" + Format$(I) + ")"
(page 182) Code at top of page:
[object.|Line[(x1, y1)| - [x2, y2) [, color| should read
[object.|Line[(x1, y1)| - (x2, y2) [, color|
(page 204) Last paragraph, second line:
"...continuous line when mouse button..." should read
"...continuous line when the left mouse button..."
(page 223) Last paragraph, second line:
"...(named GroupChoice)..." should read
"...(named GroupList)..."
(page 106) Code at bottom of page should read:
(page 248) All references to the property DrawColor should be
omitted. There is no DrawColor property.
(page 261) First paragraph, second line:
"...variable-length strings." should read
"...fixed-length strings."
(page 267) Code at bottom of page:
All references to "Picture1.Picture" should read
"Form1.Picture1.Picture"
(page 270) Code at bottom of page third line from bottom:
"...Mid$(MyTime, 1, 2)..." should read
"...Mid$(MyTime, ((Hours-12)<10)+2, 2)..."
(page 276) Third paragraph, second line:
"KeyPress event ....The same thing happens when..." should read
"KeyDown event ...The KeyDown event gets the same code when..."
(page 288) last line:
"MB_EXCLAIM" should read
"MB_ICONEXCLAMATION"
(page 308) Third paragraph of code, second nested IF THEN statement:
"If FileListBox.List(ind) = ..." should read
"If FileListBox.List(Ind%) = ..."
(page 311) The code under "FileListBox_DblClick"
"FileListBox.Pattern = *.*" should read
"FileListBox.Pattern = "*.*" "
(page 313) Do Loop should read:
Do Until Instr(LastOne% + 1, Test$, "\") = 0
LastOne% = Instr(LastOne% + 1, Test$, "\")
Loop
(page 320) Last paragraph, last sentence should read:
"The maximum length of a file that can be edited with Text
Editor is a little less than 32,000 bytes, because that is
the default maximum number of characters you can assign to a
Visual Basic multiline text box control."
(page 330) Code sample seventh to last line and (page 331) second line:
"EndLine$ = Input$(1, 1)" should read
"EndLine$ = Input$(1, FileNum)"
(page 339) The Form_Load procedure:
Running this code will result in an error: "Illegal Function
call" on the statement "FieldBoxes(0).SetFocus" on the
second-to-last line. This is because the Form is not yet
visible. To solve the problem, add the following line of code
to the top of the procedure: Form1.Show
(page 339) Code under "Form_Load":
Add the following as first line after "Sub Form_Load":
"Form1.Show"
(page 339) Code at bottom of page:
"WorkingFileNum = FileOpener..." should read
"WorkingFileNum% = FileOpener..."
(page 341) All reference to FieldBoxes in the code example on Page
341 should specify the form. For example: Form1.FieldBoxes
(page 360) Note at bottom of page:
References to the ALT key should be ESC key.
(page 364) The Link Execute Event, second argument, last line of
description:
"...the client receives a negative argument." should read
"...the client receives a negative acknowledgment."
(page 369) Program example:
"if Err = DDE_NO_APP" missing THEN statement.
(page 370) "Requesting Data from Other Applications"
All references to "warm link" should be references to "cold
link".
(page 371) "Notifying Other Applications..." first paragraph:
"(in the case of a warm link)" should read
"(in the case of a cold link)".
(page 378) "To load a custom control file:"
Delete step 2 (the second line).
"Type or select the name..." should be step 2.
(page 380) Under "Special Considerations When Declaring DLL Routines":
The statement "The Visual Basic package contains a file that
includes the declarations for all useful routines in the
operation ..." is incorrect. This file is not included with
Visual Basic, but is part of the add-on kit, "Microsoft
Windows Programmer's Reference" Book and Online Resource,
available from Microsoft at a charge.
(page 386) Code at top of page:
The first set of quotation marks around "Microsoft Excel"
should be straight quotation marks.
Add the following paragraph after first code fragment:
"The use of ByVal when passing a string is necessary because
the data type of that argument was declared As Any.
Including ByVal when passing a string declaring AsAny causes
Visual Basic to convert the string to the null-terminated
form expected by most DLL routines."
The following code at the bottom of the page:
"...Lib "User"..." should read
"...Lib "GDI"..."
(Index) A, "ALT key":
Delete "interrupting DDE 360"
A, "As Any":
Add to page list: "386"
E, after "Errors":
Add new topic: "ESC Key, interrupting DDE 360"
I, "Index property":
Add to page list on "creating control arrays": "117"
M, "Microsoft Visual Basic":
Change page list on "starting programs" from "17-18" to "16-17"
S, "Strings":
"variable-length 251, 385" should read
"use of ByVal with variable-length 251, 385, 386"
Corrections to "Microsoft Visual Basic: Language Reference"
-----------------------------------------------------------
(page 9) Windows category:
"hWin" should read
"hWnd"
(page 27) Add to the Note the following paragraph:
"When you minimize a form whose AutoRedraw Property is set to
False (0), ScaleHeight and ScaleWidth are set to icon size.
When AutoRedraw is set to True (-1), ScaleHeight and
ScaleWidth remain the size of the restored window."
(page 31) Description:
"...for an object; for forms and picture boxes..." should read
"...for an object, for forms and text boxes..."
Add the following paragraph at the end of the Remarks section:
"Because of appearance, the BorderStyle for forms with a menu
can only be set to Sizeable (2) or Fixed Single (1). Setting
the BorderStyle property to None (0) or Fixed Double (3)
forces the BorderStyle property to Fixed Single (1)."
(page 52) Graphic image:
The image shown is an example of a check box; it should show
a combo box example.
(page 147) Description:
"read-only" should read
"read-write"
Change the Note to read as follows:
"For a form icon to be functional, the BorderStyle property
must be set to either 1 (Fixed Single) or 2 (Sizeable). The
MinButton property must be set to True (-1)."
"At runtime, you can assign an object's Icon property to
another object's DragIcon or Icon property. You can also
assign an icon returned by the LoadPicture function. Doing
this assigns an empty (null) icon, which enables you to draw
on the icon at run time."
(page 154) Despite references on page 154 and in the VB.EXE
online Help, the INPUT$ function is not supported
for files opened with random access. Attempting to
use INPUT$ on a file opened for random access results
in a "Bad file mode" error message. (Use of INPUT$ on
random files was eliminated in Visual Basic, as was
the older Basic statement FIELD.)
(page 184) In the second line of the Note:
"...by pressing the ALT key." should read
"...by pressing the ESC key."
(page 188) Last line of description should read:
"The List property is not available at design time; it is
read-only for drive, file, and directory list boxes and
read-write for combo and list boxes."
(page 209) Month Function:
In the Case statements, delete all numbers greater than 12.
(page 244) Pointer Property:
This property does not exist. The name was changed to
MousePointer Property (page 214).
(page 285) Syntax:
The syntax fo ClipBoard.SetData should be changed from
"ClipBoard.SetData (data%, [format%|) to
"Clipboard.SetData data%, [format%|"
Title: Correction to WINAPI.TXT for Visual Basic Add-on Kit
Document Number: Q74526 Publ Date: 21-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
The following corrections apply to the WINAPI.TXT file provided on
disk with the "Microsoft Windows Programmer's Reference" book and
Online Resource, add-on kit number 1-55615-413-5, for Microsoft Visual
Basic.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
The following corrections apply to the WINAPI.TXT file dated 5/14/91.
1. The following statement is incorrect
Declare Function SetCommState Lib "User" ()
and should be changed to read as follows:
Declare Function SetCommState Lib "User" (lpDCB as DCB) As Integer
2. The Declare statement for WinExec is missing the ByVal attribute in
the second parameter. Without this ByVal, invoking WinExec can cause
a Windows "Unrecoverable Application Error" ("UAE"). The WinExec
Declare statement should be changed to read as follows (on one line):
Declare Function WinExec Lib "Kernel" (ByVal lpCmdLine As String,
ByVal nCmdShow As Integer) As Integer
3. The following statement is incorrect
GetDC Lib "GDI" (ByVal hWnd As Integer) As Integer
and should be changed to read as follows:
GetDC Lib "USER" (ByVal hWnd As Integer) As Integer
In other words, the function GetDC is in the Windows "USER"
library (DLL), not in the "GDI" library (DLL).
4. The following statement is incorrect
Declare Function WinExec Lib "Kernel" (ByVal lpCmdLine As String,
nCmdShow As Integer) As Integer
and should be changed to read as follows:
Declare Function WinExec Lib "Kernel" (ByVal lpCmdLine As String,
ByVal nCmdShow As Integer) As Integer
For more information on WINAPI.TXT, query on the following words:
WINAPI.TXT and Visual and Basic
Title: DDE from Visual Basic to Excel for Windows
Document Number: Q75089 Publ Date: 21-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
This article describes how to initiate a dynamic data exchange (DDE)
conversation between a Visual Basic client application and a Microsoft
Excel server application.
This article demonstrates how to:
- Prepare a Microsoft Excel document for active DDE.
- Initiate a cold DDE link (information updated upon request from the
client) between Visual Basic (the client) and Excel (the server).
- Use LinkRequest to update information in Visual Basic (the client)
based on information contained in Excel (the server).
- Initiate a hot DDE link (information updated automatically from
server to client) between Visual Basic (the client) and Excel
(the server).
- Use LinkPoke to send information from Visual Basic (the client) to
Excel (the server).
- Change the LinkMode property between hot and cold.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows and to Microsoft Excel for Windows.
More Information:
A client application sends commands through DDE to the server
application to establish a link. Through DDE, the server provides data
to the client at the request of the client or accepts information at
the request of the client.
The steps below serve as a example of how to establish a DDE
conversation between Visual Basic and Excel for Windows.
First, create the server spreadsheet in Excel:
1. Start Excel, and a document titled "SHEET1" will be created by
default.
2. From the File menu, choose Save As, and save the document with the
name SERVER.XLS
4. Exit Excel. For this example to function properly, Excel must not
be loaded and running.
Second, create the client application in Visual Basic:

The client is the application that performs the link operations. It
prompts the server to send information or informs the server that
information is being sent.
1. Start Visual Basic (VB.EXE), and Form1 will be created by default.
2. Create the following controls with the following properties on
Form1:
Default Name Caption CtlName
------------ ------- -------
Text1 (not applicable) Text1
Option1 Cold Link ColdLink
Option2 Hot Link HotLink
Command1 Poke Poke
Command2 Request Request
3. Add the following code to the General Declaration section of Form1:
Const TRUE = -1
Const FALSE = 0
Const HOT = 1
Const COLD = 2
Const NONE = 0
4. Add the following code to the Load event procedure of Form1:
Sub Form_Load ()
'This procedure will start Excel and load SERVER.XLS, the
'spreadsheet that was created earlier.
z% = Shell("C:\EXCEL\EXCEL c:\excel\SERVER.XLS", 1)
z% = DoEvents() 'Process Windows events. This ensures
'that Excel will be executed before
'any attempt is made to perform DDE.
Text1.LinkMode = NONE 'Clears DDE link if it already exists.
Text1.LinkTopic = "Excel]c:\excel\server.xls" 'Sets up link
'with Excel.
Text1.LinkItem = "R1C1" 'Set link to first cell on spreadsheet.
Text1.LinkMode = COLD 'Establish a cold DDE link.
ColdLink.Value = TRUE
End Sub
5. Add the following code to the Click event procedure of the
Cold Link button:
Sub ColdLink_Click ()
Request.Visible = TRUE 'Make request button valid.
Text1.LinkMode = NONE 'Clear DDE Link.
Text1.LinkMode = COLD 'Reestablish new LinkMode.
End Sub
6. Add the following code to the Click event procedure of the
Hot Link button:
Sub HotLink_Click ()
Request.Visible = FALSE 'No need for button with hot link.
Text1.LinkMode = NONE 'Clear DDE Link.
Text1.LinkMode = HOT 'Reestablish new LinkMode.
End Sub
7. Add the following code to the Click event procedure of the
Request button:
Sub Request_Click ()
'With a cold DDE link this button will be visible and when selected
'it will request an update of information from the server
'application to the client application.
Text1.LinkRequest
End Sub
8. Add the following code to the Click event procedure of the Poke
button:
Sub Poke_Click ()
'With any DDE link this button will be visible and when selected
'it will poke information from the client application to the
'server application.
Text1.LinkPoke
End Sub
You can now run the Visual Basic client application from the Visual Basic
environment (skip to step 4) or you can save the application and
create an EXE file and run that from Windows (continue to step 1):
1. From the Visual Basic File menu, save the Form and Project with the
name CLIENT.
2. From the File menu, choose Make EXE File, and name it CLIENT.EXE.
3. Exit Visual Basic.
4. Run the application (from Windows if an .EXE file or from the Run
menu if from the Visual Basic environment).
5. Form1 of the client application will be loaded and Excel will
automatically be started with the document SERVER.XLS loaded.
6. Make sure that the main title bar in Excel reads
"Microsoft Excel," NOT "Microsoft Excel - SERVER.XLS." If the title
bar is improper, then from the Window menu choose ArrangeAll.
You can now experiment with DDE between Visual Basic and Excel:
1. Try typing in some text in R1C1 in the spreadsheet and then
select the Request button. The text appears in the text box.
2. Choose Hot Link and then type in some more text in R1C1 of the
spreadsheet. The text is automatically updated in the Visual
Basic text box.
3. Type some text in the text box in the Visual Basic application and
select the Poke button. The text is sent to R1C1 in the Excel
spreadsheet.
Note that if you have "Ignore Remote Requests" checked in the
"Options" - "Work space" menu, you will not be able to establish DDE
from Visual Basic. Make sure that "Ignore Remote Requests" is NOT checked.
You can also establish DDE between applications at design time. This
is covered on page 356 in the "Microsoft Visual Basic: Programmer's
Guide" version 1.0 manual.
For additional information on dynamic data exchange (DDE) between
Microsoft Visual Basic version 1.0 and other Windows applications,
query on the following words:
DDE and Visual Basic
Title: DDE Between Visual Basic and Q+E for Windows
Document Number: Q75090 Publ Date: 21-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
This article describes how to initiate a dynamic data exchange (DDE)
conversation between a Visual Basic client application and a Q+E
server application.
This article demonstrates how to:
1. Prepare a Q+E database file for active DDE.
2. Initiate a cold DDE link (information updated upon request from the
client) between Visual Basic (the client) and Q+E (the server).
3. Use LinkRequest to update information in Visual Basic (the client)
based on information contained in Q+E (the server).
4. Initiate a hot DDE link (information updated automatically from
server to client) between Visual Basic (the client) and Q+E (the
server).
5. Use LinkPoke to send information from Visual Basic (the client) to
Q+E (the server).
6. Change the LinkMode property between hot and cold.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows and to Pioneer Software Q+E (a database query
tool).
More Information:
A client application sends commands through DDE to the server
application to establish a link. Through DDE, the server provides data
to the client at the request of the client or accepts information at
the request of the client.
The following steps serve as a example of how to establish a DDE
conversation between Visual Basic and Pioneer Software Q+E for Windows.
First, generate a Q+E database file to act as the server.
1. Create a database (.DBF) file (see the Q+E manuals for the
procedure). For this example, you will use one of the default
files, ADDR.DBF, that was provided with Excel for Windows.
2. If Q+E is already running, exit Q+E. For this example to work
properly, Q+E must not be loaded and running.
Next, create the client application in Visual Basic.
The client is the application that performs the link operations. It
prompts the server to send information or informs the server that
information is being sent.
1. Start Visual Basic. Form1 will be created by default.
2. Create the following controls with the following properties on
Form1:
Default Name Caption CtlName
------------ ------- -------
Text1 (not applicable) Text1
Option1 Cold Link ColdLink
Option2 Hot Link HotLink
Command1 Poke Poke
Command2 Request Request
3. Add the following code to the General Declaration section of Form1:
Const TRUE = -1
Const FALSE = 0
Const HOT = 1
Const COLD = 2
Const NONE = 0
4. Add the following code to the Load event procedure of Form1:
Sub Form_Load () 'This procedure will start Q+E and load the
'file "ADDR.DBF"
z% = Shell("C:\EXCEL\QE C:\EXCEL\QE\ADDR.DBF",1)
z% = DoEvents () 'Process Windows events. This
'ensures that Q+E will be
'executed before any attempt is
'made to perform DDE with it.
Text1.LinkMode = NONE 'Clears DDE link if it already
'exists.
Text1.LinkTopic = "QE]QUERY1" 'Sets up link with Q+E.
Text1.LinkItem = "R1C1" 'Set link to first cell on
'spreadsheet.
Text1.LinkMode = COLD 'Establish a cold DDE link.
ColdLink.Value = TRUE
End Sub
5. Add the following code to the Click event procedure of the
Cold Link button:
Sub ColdLink_Click ()
Request.Visible = TRUE 'Make request button valid.
Text1.LinkMode = NONE 'Clear DDE Link.
Text1.LinkMode = COLD 'Reestablish new LinkMode.
End Sub
6. Add the following code to the Clink event procedure of the
Hot Link button:
Sub HotLink_Click ()
Request.Visible = FALSE 'No need for button with hot link.
Text1.LinkMode = NONE 'Clear DDE Link.
Text1.LinkMode = HOT 'Reestablish new LinkMode.
End Sub
7. Add the following code to the Click event procedure of the
Request button:
Sub Request_Click ()
'With a cold DDE link this button will be visible and when
'selected it will request an update of information from the server
'application to the client application.
Text1.LinkRequest
End Sub
8. Add the following code to the Click event procedure of the Poke
button:
Sub Poke_Click ()
'With any DDE link this button will be visible and when selected
'it will poke information from the client application to the
'server application.
Text1.LinkPoke
End Sub
You can now run the Visual Basic client application from the Visual
Basic environment (skip to step 4) or you can save the application and
create an .EXE file and run that from Windows (continue to step 1):
1. From the File menu, save the Form and Project using the name
CLIENT.
2. From the File menu, choose Make an EXE File, and name it
CLIENT.EXE.
3. Exit Visual Basic.
4. Run the application (from Windows if an .EXE file or from the Run
menu if from the Visual Basic environment).
5. Form1 of the client application will be loaded and Q+E will
automatically be started with the database file ADDR.DBF loaded.
6. Make sure that the main title bar in Q+E reads "Q + E," NOT
"Q + E - ADDR.DBF." If the title bar is incorrect, then from the
Window menu of Q+E choose ArrangeAll.
You can now experiment with DDE between Visual Basic and Q+E for
Windows:
1. Try typing in some text in R1C1 (the cell that holds the name
"Tyler") in the Q+E spreadsheet and then select the Request button.
The text will appear in the Visual Basic text box.
2. Choose Hot Link and then type in some more text in R1C1 of the Q+E
spread sheet. The text is automatically updated in the Visual Basic
text box.
3. Type some text in the text box in the Visual Basic application and
select the Poke button. The text is sent to R1C1 in the Q+E
spreadsheet.
Note that if you do not have the Allow Editing option checked under
the Edit menu in Q+E, you will not be able to change the contents of
the Q+E spreadsheet. This may prevent some DDE operations. For
example, attempting to LinkPoke to Q+E from Visual Basic when the
Allow Editing option is not selected will cause the program to crash
and result in a "Foreign application won't perform DDE method or
operation" error message. Attempting to change the contents of the
spreadsheet from Q+E will result in a "Use the allow editing command
before making changes" error message. From the Edit menu of Q+E,
select Allow Editing to enable this option. When viewed from the edit
menu, it should have a check mark next to it when enabled.
You can also establish DDE between applications at design time. For
more information, see page 356 of the "Microsoft Visual Basic:
Programmer's Guide" version 1.0 manual.
For additional information on dynamic data exchange (DDE) between
Microsoft Visual Basic version 1.0 and other Windows applications,
query on the following words:
DDE and Visual Basic
Title: Cannot Make DDE Link to Object as Child of Another Object
Document Number: Q75091 Publ Date: 21-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
When performing dynamic data exchange (DDE) from a client application
to a Visual Basic server application, you cannot make a DDE
link to an object that is not a direct child of a Form in the Visual
Basic application.
For example, from Excel you cannot establish a DDE link with a text
box in a Visual Basic application if that text box is contained within
a picture box on Form1.
The text box must be on Form1 and not a child of any other object on
that form.
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. Microsoft is researching
this problem and will post new information here as it becomes
available.
More Information:
To work around this problem, create an additional object on the form
and set that object's Visible property to False. You can then
establish a DDE link with this hidden object.
Establishing a DDE link with a hidden object will issue the Change
event for this object. You can attach code to this event that will
update the information sent via the DDE link to the appropriate
control, which may or may not be a direct child of the form.
The following example demonstrates this workaround:
First, create the server application in Visual Basic:
1. Start Visual Basic, and Form1 will be created by default.
2. Put a text box (Text1) on Form1.
3. Save the Form and Project with the name SERVER.
4. From the File menu, choose Make EXE File, make an .EXE, and call it
SERVER.EXE.
Next, create the client application in Visual Basic:
1. From the File menu, choose New Project. Form1 will be created by
default.
2. Put a picture box (Picture1) on Form1.
3. Put a text box (Text1) in the picture box (Picture1) as follows:
a. Click ONCE on the text box icon in the toolbox.
b. Move the mouse pointer on top of Picture1 (note the mouse
pointer is a cross).
c. Press the left mouse button and drag the mouse pointer to
size the text box.
d. Release the left mouse button.
e. Text1 is now a child of Picture1.
4. Put a text box (Text2) on Form1.
5. Set the Visible property of Text2 to False.
6. Add the following code to the General Declaration section of Form1:
Const NONE = 0
Const HOT = 1
7. Add the following code to the Form_Load event procedure of Form1:
Sub Form_Load ()
'This procedure will start the Visual Basic server application
'that was created earlier.
Form1.Show 'Show Form1
z% = Shell("C:\VB\SERVER,1)
z% = DoEvents() 'Causes Windows to process the Shell.
Text2.LinkMode = NONE 'Clears DDE Link if already there.
Text2.LinkTopic = "Server]Form1" 'Sets up link with VB server.
Text2.LinkItem = "Text1" 'Sets link to Text Box on server.
Text2.LinkMode = HOT 'Establish a hot DDE link.
End Sub
8. Add the following code to the Change event procedure of Text1:
Sub Text2_Change ()
'This procedure will cause the information in the text field of
'Text1 to be updated whenever the text property of Text2 changes.
Text1.Text = Text2.Text
End Sub
You can now run the VB client application:
1. From the Run menu, choose Start.
2. Form1 of the client application will be loaded and the Visual Basic
server application will automatically be started.
3. Now any information you type in the text box of the Server
application will be automatically updated to the invisible text box
(on Form1) in the client application and then automatically
transferred to the Visible text box (on Picture1 on Form1) in the
client application.
Title: Duplicate PostScript Font Names in VB Printer.Fonts List
Document Number: Q75092 Publ Date: 21-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
When a PostScript printer driver is active in Microsoft Windows 3.0,
the Fonts(index%) property of Visual Basic's Printer object may return
one or more duplicate font names at run time. This problem is caused
by Microsoft Windows 3.0 itself (and is not caused by Microsoft Visual
Basic programming system version 1.0 for Windows).
Microsoft has confirmed this to be a problem with Microsoft Windows
version 3.0 (buglist3.00). We are researching this problem and will
post new information here as it becomes available.
More Information:
The following program displays the list of font names available for
the PostScript printer currently selected in the Windows Control Panel:
Sub Form_Click ()
For J% = 0 to Printer.FontCount - 1
Print Printer.Fonts(J%)
Next J%
End Sub
In some cases, when a PostScript printer is active in Windows, one or
more fonts are listed twice.
Title: Some Invalid DrawMode Values Return 1-16 Instead of Error
Document Number: Q75174 Publ Date: 21-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
The Microsoft Visual Basic DrawMode property will not give an error
for some invalid values. For example, numbers in the range 257 to 272,
513 to 528, and so forth, and for negative numbers in the range -240
to -255, -496 to -511, and so forth.
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
More Information:
The code below demonstrates the problem. When you run this program,
the DrawMode is assigned to 257, and when the DrawMode is printed, it
prints 1, showing that the values are mapping onto 1 through 16.
Example
-------
1. In the VB.EXE environment, create a New Form.
2. In the Form_GotFocus event procedure, add the following lines of
code:
DrawMode = 257
Print DrawMode
3. Run the program (press F5). The program will incorrectly display a
1 on the form, instead of giving the error message "Illegal
Property Value."
By analyzing the range of values that map onto 1 through 16, any
number that satisfies the following equation will not generate an
error, but will instead give values in the range of 1 to 16:
Number = (x * 256) + y
where x is a whole number between -128 and 127, and y is between 1 and
16 inclusive (that is, any number in the range of a multiple of 256
plus 1 to 16 will map onto 1 through 16).
Title: Using Code Menu's Replace to Create Subs May Fail in VB.EXE
Document Number: Q75057 Publ Date: 22-AUG-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
When using the Replace command from the Code menu of Microsoft
Visual Basic to perform a replacement that results in the creation of
a Sub or Function, Visual Basic may not correctly perform the
replacement.
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. Microsoft is researching
this problem and will post new information here as it becomes
available.
More Information:
Steps to Reproduce Problem
--------------------------
1. Start the Visual Basic environment (VB.EXE).
2. Double-click on Form1 to bring up a code window.
3. Select the (general) object from the object list box at the top of
the code window.
4. Type the following text in the code window:
'test1
'test2
'test3
'test4
5. From the Code menu, choose the Replace command.
6. Type the following on the "Find What:" line of the Replace dialog
box:
'test
7. Type the following on the "Replace With:" line of the same dialog
box:
sub test
8. If you now choose the Verify button, Visual Basic will prompt you
to replace the text for the lines 'test1 and 'test3, but not for
'test2 or 'test4. If you choose Replace All, Visual Basic will
correctly create Sub test1 and Sub test2, but will fail to replace
the text for 'test3 or 'test4. (The order of replacement
depends upon the location of the insertion point.)
Title: How to Determine Multiple Instances of a VB Application
Document Number: Q75641 Publ Date: 9-SEP-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Using Windows version 3.0 API function calls, you can determine if
another instance of your application is running. Using the same API
calls, you can also determine how many instances of an application are
running.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
You can use two Windows API function calls to determine how many
instances of your application are running. This can be useful if you
want to limit how many copies of your application can run at once.
The Windows KERNEL DLL (dynamic-link library) defines two functions
called GetModuleHandle and GetModuleUsage. GetModuleUsage uses the
handle returned from GetModuleHandle to determine how many instances
of your application are running. Below is a definition of each
function:
GetModuleHandle%(lpProgramName$)
--------------------------------
This function retrieves the program handle of the specified program.
lpProgramName$ Points to a null-terminated character string that
specifies the program.
Return Value The return value identifies the program if the
function is successful. Otherwise, the return value is
zero.
GetModuleUsage%(hProgram%)
--------------------------
This function returns the reference count of a specified program.
hProgram% Identifies the program or an instance of the program.
This value can be determined with a call to
GetModuleHandle.
Return Value The return value specifies the reference count of
the program.
Example
-------
The following application is an example of how to limit an application
to a single instance:
1. Create a form called Form1.
2. Within the global-declaration section of the form, declare the
following Windows API functions:
Declare Function GetModuleHandle% Lib "Kernel" (ByVal lpProgramName$)
Declare Function GetModuleUsage% Lib "Kernel" (ByVal hProgram%)
3. Within the Form_Load event add the following code:
Sub Form_Load ()
hw% = GetModuleHandle("project.EXE")
If GetModuleUsage(hw%) > 1 Then
MsgBox "This program is already loaded!", 16
End
End If
End Sub
4. Compile the program as PROJECT.EXE
5. Run PROJECT.EXE from the Program Manager.
6. Run a second instance of PROJECT.EXE. It should display a message
box and terminate.
Reference:
"Programming Windows: the Microsoft Guide to Writing Applications for
Windows 3," by Charles Petzold (published by Microsoft Press, 1990)
"Microsoft Windows 3.0 Software Development Kit: Reference Volume 1"
WINSDK.HLP file shipped with Microsoft Windows 3.0 Software
Development Kit
Title: Text Not Highlighted Copying Immediate Window to Clipboard
Document Number: Q75762 Publ Date: 9-SEP-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
When you copy text from the Immediate window to the Windows system
clipboard, the selected text is not highlighted. Also, the cursor is
not visible. However, the copy operation works as it should.
This information applies to Microsoft Visual Basic programming system
version 1.0 for windows.
Microsoft has confirmed this problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
More Information:
To reproduce the problem, perform the following steps:
1. Run the Windows Clipboard utility. (Usually found in the Windows
MAIN group window).
2. Run Visual Basic.
3. Press F5 to start Visual Basic.
4. Press CTRL+BREAK to bring up the Immediate window.
5. Press F5 to continue.
6. Click on the Immediate window to give it the focus.
7. Press CTRL+HOME to move to the beginning of the text in the
Immediate window.
8. Press SHIFT+CTRL+END (this selects all text in the Immediate
window. Note that you cannot select text with the Mouse at this
point).
9. Press CTRL+INS (this copies the selected text in the Immediate
window to the Windows clipboard).
The text transfers to the Windows clipboard as it should, but the text
in the Immediate window is not highlighted as it should be. The cursor
is also not visible.
Title: How to Print the ASCII Character Set in Visual Basic
Document Number: Q75857 Publ Date: 9-SEP-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
The default font used by Visual Basic is the standard ANSI character
set. To display the ASCII character set, which is more commonly used
by DOS mode applications, you must call two different Windows API
functions. The Windows API functions are GetStockObject and
SelectObject.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
Windows supports a second character set, referred to as the OEM
character set. This is generally the character set used internally by
DOS for screen display at the DOS prompt. The character codes 32 to
127 are normally identical for the OEM, ASCII, and ANSI character
sets. The ANSI characters represented by the remaining character codes
(codes 0 to 31 and 128 to 255) are generally different from characters
represented by the OEM and ASCII character sets. The OEM and ASCII
character sets are identical for these ranges. Under the ASCII and OEM
character sets, the character codes 128 to 255 correspond to the
extended ASCII character set, which includes line drawing characters,
"graphics" characters, and special symbols. The characters represented
by this range of character codes generally differ between the ASCII
(or OEM) and ANSI character sets.
To change the selected font from ANSI to the OEM ASCII font, you must
get a handle to the OEM character set by calling GetStockObject. When
this handle is passed as an argument to SelectObject, the ANSI font
will be replaced by the OEM ASCII font. This API function also returns
the handle to the font object previously used. Once you are through
displaying the desired characters, you should call SelectObject again
to reselect the original font object.
Note: There is also an API function called DeleteObject. This function
need not be called to delete a stock object. The purpose of this API
function is to delete objects loaded with the API function GetObject.
The three functions are described as follows:
GetStockObject% (nIndex%)
-------------------------
nIndex%
Specifies the type of stock object desired. Use the constant
OEM_FIXED_FONT to retrieve the handle to the OEM character set.
The value of this constant is 10.
Return Value
The return value identifies the desired logical object if the
function is successful. Otherwise, it is NULL.
SelectObject% (hDC%, hObject%)
------------------------------
hDC%
Identifies the device context.
hObject%
Identifies the object to be selected. Use the return value from
GetStockObject% (above) to select the OEM character set.
Return Value
The return value identifies the handle to the object previously
used. This value should be saved in a variable such that
SelectObject can be called again to restore the original object
used. It is NULL if there is an error.
The following steps describe how to create a program example that
demonstrates how to print ASCII characters.
1. Run Visual Basic.
2. From the File menu, choose New Project (ALT, F, N).
3. Create a command button called Command1 on the default form
(Form1).
4. Add the following declarations to the General Declarations section
of Form1.
Declare Function GetStockObject% Lib "GDI" (ByVal nIndex%)
Declare Function SelectObject% Lib "GDI" (ByVal hdc%, ByVal hObject%)
5. Place the following code in the Command1 click event procedure:
Sub Command1_Click ()
Const OEM_FIXED_FONT = 10
Const PIXEL = 3
Dim hOEM As Integer '* handle to the OEM font object
Dim Y, H As Single
'* save the scale mode so that you can reset later
Saved% = Form1.ScaleMode
Form1.ScaleMode = PIXEL
'* Get the character height and subtract the external leading
H = Form1.TextHeight(Chr$(200)) - 1
'* get the handle to the desired font
hOEM = GetStockObject(OEM_FIXED_FONT)
'* select the object relating to the font handle, if
'* successful then print the desired characters.
PreviousObject% = SelectObject(Form1.hDC, hOEM)
If PreviousObject% Then
Form1.CurrentX = 10: Form1.CurrentY = 10
Print Chr$(201); Chr$(187);
Form1.CurrentX = 10:
Form1.CurrentY = Form1.CurrentY + H
Print Chr$(200); Chr$(188)
'* Reinstate previous font
hOEM = SelectObject(Form1.hDC, PreviousObject%)
Else
'* SelectObject was unsuccessful
MsgBox "Couldn't find OEM fonts", 48
End If
'* reset the scale mode
Form1.ScaleMode = Saved%
End Sub
6. From the Run menu, choose Start.
7. Click the Command1 button.
When the Command1 button is clicked or selected, a small box with a
double border will be drawn in the upper-left corner of the screen.
The box is drawn using characters associated with the extended ASCII
character set.
References:
1. "Programming Windows: the Microsoft Guide to Writing Applications
for Windows 3," by Charles Petzold (published by Microsoft Press,
1990)
2. "Peter Norton's Windows 3.0 Power Programming Techniques," by
Peter Norton & Paul Yao (published by Bantam Computer Books, 1990)
3. "Microsoft Windows 3.0 Software Development Kit: Reference
Volume 1"
4. The WINSDK.HLP file shipped with Microsoft Windows 3.0 Software
Development Kit.
Title: Simulating ON KEY Key Trapping with KeyDown Event in VB
Document Number: Q75858 Publ Date: 9-SEP-1991
Product Name: Microsoft Visual Basic
Product Version: 1.00
Operating System: WINDOWS

Summary:
Although there is no ON KEY GOSUB statement in Visual Basic, the
effect of ON KEY event handling can be achieved in Visual Basic.
Visual Basic forms and controls that are able to get focus within
Visual Basic have a [form/control|_KeyDown event procedure that can
simulate the effects of the ON KEY statements of DOS-based Basics. The
process of using the KeyDown is more powerful and more flexible than
the ON KEY statement.
This information applies to the Microsoft Visual Basic programming
system version 1.0 for Windows.
More Information:
If you press a key while one of your Visual Basic forms or controls
has the focus, the KeyDown event procedure for that form or control
will be executed. Within the KeyDown event procedure, you can call a
global procedure and pass the actual key states to the global
procedure to create the same effect as the ON KEY event trapping that
is performed in the DOS-based Basic.
You can also pass the control or form where the KeyDown occurred to
the global procedure. Passing the control or form itself will allow
the global procedure to tell what control or form called the global
procedure.
To create a small example, perform the following steps:
1. Within Visual Basic's Project window, double-click the GLOBAL.BAS
file to bring up the code window. From Visual Basic's Code menu,
choose "Load text...". Load the CONSTANTS.TXT file that came with
Visual Basic. Note: If you already have text within the GLOBAL.BAS
file, you will need to create another module, add the CONSTANTS.TXT
to this file, and then cut and paste to the GLOBAL.BAS file.
2. Create two text boxes on a form.
3. In the Text1_KeyDown event procedure, add the following code:
Call OnKeyGoSub(KeyCode, Shift, Text1)
4. In the Text2_KeyDown event procedure, add the following code:
Call OnKeyGoSub(KeyCode, Shift, Text2)
5. Add a Label to Form1 called Label1.
6. At the global-declaration section for form1, add the following
procedure:
Sub OnKeyGoSub (KeyCode%, Shift%, Ctrl As Control)
Select Case KeyCode%
Case KEY_MENU: Key$ = ""
Case KEY_SHIFT: Key$ = ""
Case KEY_CONTROL: Key$ = ""
Case KEY_F1: Key$ = " F1 "
Case KEY_UP: Key$ = " UP key"
Case KEY_CAPITAL: Key$ = "CAP LOCKS"
Case Else: Key$ = Chr$(KeyCode%)
End Select
Select Case Shift%
Case SHIFT_MASK: Shft$ = "Shift"
Case ALT_MASK: Shft$ = "Alt"
Case CTRL_MASK: Shft$ = "Ctrl"
Case Else: Shft$ = ""
End Select
ControlName$ = Ctrl.CtrlName
Label1.Caption="Key:"+ Shft$+ " "+ Key$+" from "+ ControlName$
End Sub
7. Run the program. Move back and forth between the two text boxes
using either the TAB key or the mouse. Experiment with any key in
combination with the ALT, CTRL, and SHIFT keys. Also try the F1 key
and the UP ARROW key.
This example is limited but shows how you could simulate the ON KEY
statements or key trapping within Visual Basic. Placing the call to
the key trap procedure within any KeyDown event procedure will
simulate the ON KEY statement.


 December 22, 2017  Add comments

Leave a Reply