Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


The title parameter holds the string displayed in the title bar of the dialog box. (If you don’t 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.

Table 4.3 MsgBox() return values.
Constant Value Description
vbOK 1 OK
vbCancel 2 Cancel
vbAbort 3 Abort
vbRetry 4 Retry
vbIgnore 5 Ignore
vbYes 6 Yes
vbNo 7 No

The InputBox() Function

You can use the InputBox() function to get a string of text from the user. Here’s 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 don’t 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 Procedures

You can pass forms to procedures just as you would any object. Here, we’ve 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 we’ve 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 that’s all it takes to pass a form to a procedure.

Minimizing/Maximizing And Enabling/Disabling Forms From Code

To exert a little more control over the windows in your programs, you can set the WindowState property to maximize or minimize them. Here’s how you set that property, and what those settings mean:

  0—Normal
  1—Minimized
  2—Maximized

Here’s 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 it’s 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.


Previous Table of Contents Next


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.