|
|
![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
The title parameter holds the string displayed in the title bar of the dialog box. (If you dont specify title, the application name is placed in the title bar.) The helpfile argument is a string that identifies the Help file to use to provide context-sensitive Help for the dialog box. The context argument is the Help context number assigned to the appropriate Help topic. The possible return values from MsgBox() appear in Table 4.3.
The InputBox() Function You can use the InputBox() function to get a string of text from the user. Heres the syntax for this function: InputBox(prompt[, title] [, default] [, xpos] [, ypos] [, helpfile, context]) The prompt argument is a string displayed as the message in the dialog box. The title argument is a string displayed in the title bar of the dialog box. (If you dont specify the title, the application name is placed in the title bar.) The default argument is a string displayed in the text box as the default response if no other input is provided. The xpos argument is a number that specifies (in twips) the horizontal distance of the left edge of the dialog box from the left edge of the screen. The ypos argument is a number that specifies (in twips) the vertical distance of the upper edge of the dialog box from the top of the screen. The helpfile argument is a string that identifies the Help file to use to provide context-sensitive Help for the dialog box. The context argument is the Help context number assigned to the appropriate Help topic. The InputBox() function returns the string the user entered. Passing Forms To ProceduresYou can pass forms to procedures just as you would any object. Here, weve set up a subroutine, ColorWindowWhite(), to turn the background color of a form to white: Sub ColorWindowWhite(FormToColor As Form) End Sub In this case, we can simply refer to the form passed to this subroutine by the name weve given the passed parameter, FormToColor :
Sub ColorWindowWhite(FormToColor As Form)
FormToColor.BackColor = RGB(255, 255, 255)
End Sub
Now you can pass a form to the ColorWindowWhite() subroutine easily:
Private Sub Command1_Click()
ColorWindowWhite Me
End Sub
And thats all it takes to pass a form to a procedure. Minimizing/Maximizing And Enabling/Disabling Forms From CodeTo exert a little more control over the windows in your programs, you can set the WindowState property to maximize or minimize them. Heres how you set that property, and what those settings mean:
Heres an example, where we minimize a form when the user clicks a button:
Private Sub Command1_Click()
WindowState = 1
End Sub
You can also set the Enabled property to enable or disable a window (when its disabled, it will only beep if the user tries to give it the focus). You set the Enabled property to True to enable a window and to False to disable it.
|
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. |