WIDTH # Statement Raises Error in Visual Basic 4.0Last reviewed: February 8, 1996Article ID: Q145678 |
The information in this article applies to:
SUMMARYThe WIDTH # statement is used to assign an output-line width to a file opened using the Open statement. However, the sample code given in Visual Basic 4.0 does not work in a form. STEPS TO REPRODUCE
MORE INFORMATIONThe problem is that Visual Basic 4.0 interprets the "Width" statement as a property of the Form when the code is run from a Form module. When run from a Code module or a Class module, the statement functions as documented because there is no default object on which to apply the Width property. Visual Basic 4.0 can be forced to use the correct Width statement in this case by specifying the call using "Typelib.Method" syntax. The Width statement is actually a "Visual Basic for Applications" (VBA) method, so the following syntax must be used:
VBA.Width filenum, width Private Sub Command1_Click() Open "TESTFILE" For Output As #1 VBA.Width 1, 5 ' Note: "#" symbol omitted For I = 0 To 9 Print #1, Chr(48 + I); Next I Close #1 End SubNOTE: The compiler will not accept this statement unless the "#" symbol is removed.
|
Additional reference words: 4.00 vb4win vb4all
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |