Interaction Module

 <  Day Day Up  >  

The Interaction module contains subroutines and functions that assist in interacting with the runtime environment.

 Public Sub AppActivate(ByVal ProcessId As Integer) Public Sub AppActivate(ByVal Title As String) 

The AppActivate subroutine switches the active application on the desktop to the specified application. The argument can be either the Integer process ID of the process to switch to or the title of the window.

 Public Sub Beep() 

The Beep subroutine makes a lovely sound through the computer's speakers .

 Public Function CallByName(ByVal ObjectRef As Object, _   ByVal ProcName As String, ByVal UseCallType As CallType, _   ByVal ParamArray Args() As Object) As Object 

The CallByName function simulates a late-bound method call or a late-bound index. The ObjectRef parameter is the instance on which the call will be made. The ProcName parameter specifies the name of the method to call (this parameter should be Nothing to call the default property). The UseCallType parameter specifies the type of call to be made, and the Args parameter array specifies the arguments to pass to the call. The function returns the value returned by the call.

 Public Function Choose(ByVal Index As Double, _   ByVal ParamArray Choice() As Object) As Object 

The Choose function selects and returns a value from among the parameter array. The Index parameter indicates which of the parameters to return.

 Public Function Command() As String 

The Command function returns the argument portion of the command line used to start the current program.

 Public Function CreateObject(ByVal ProgId As String, _   Optional ByVal ServerName As String = "") As Object 

The CreateObject function creates and returns a reference to a COM object. The ProgId parameter specifies the type of COM object to create, and the ServerName parameter specifies the name of the network server where the object should be created (an empty string specifies that the local machine should be used).

NOTE

To create a .NET Framework object at runtime, you can use the function System.Activator.CreateInstance .


 Public Sub DeleteSetting(ByVal AppName As String, _   Optional ByVal Section As String = Nothing, _   Optional ByVal Key As String = Nothing) 

The DeleteSetting subroutine deletes a section or a key from the application's section in the Windows registry.

 Public Function Environ(ByVal Expression As Integer) As String Public Function Environ(ByVal Expression As String) As String 

The Environ function returns the value of the specified environment variable. If Expression is an Integer , the variable is fetched by position. If Expression is a String , the variable is fetched by name.

 Public Function GetAllSettings(ByVal AppName As String, _   ByVal Section As String) As String(,) 

The GetAllSettings function returns all the values from an application's section in the Windows registry. The return value is a two-dimensional array of keys and settings.

 Public Function GetObject(Optional ByVal PathName As String = Nothing, _   Optional ByVal [Class] As String = Nothing) As Object 

The GetObject function returns a reference to an object provided by a COM component. The PathName parameter specifies the path from which to load the object. If PathName is not specified, the Class parameter must be specified. The Class parameter specifies the class of the object to load.

 Public Function GetSetting(ByVal AppName As String, _   ByVal Section As String, ByVal Key As String, _   Optional ByVal [Default] As String = "") As String 

The GetSetting function returns the value of a specified key from the application's section in the Windows registry.

 Public Function IIf(ByVal Expression As Boolean, _   ByVal TruePart As Object, ByVal FalsePart As Object) As Object 

The IIf function returns a value based on a Boolean expression. ( IIf stands for "Immediate If.") If Expression is True , IIf returns the TruePart parameter. If Expression is False , IIf returns the FalsePart parameter.

NOTE

IIf does not short-circuit . Both the TruePart and FalsePart expressions will be evaluated, regardless of the value of Expression .


 Public Function InputBox(ByVal Prompt As String, _   Optional ByVal Title As String = "", _   Optional ByVal DefaultResponse As String = "", _   Optional ByVal XPos As Integer = -1, _   Optional ByVal YPos As Integer = -1) As String 

The InputBox function displays a prompt, waits for the user to input text or click a button, and then returns a string containing the contents of the text box.

 Public Function MsgBox(ByVal Prompt As Object, _   Optional ByVal Buttons As MsgBoxStyle = MsgBoxStyle.OKOnly, _   Optional ByVal Title As Object = Nothing) As MsgBoxResult 

The MsgBox displays a message, waits for the user to click a button, and then returns which button the user clicked.

 Public Function Partition(ByVal Number As Long, ByVal Start As Long, _   ByVal [Stop] As Long, ByVal Interval As Long) As String 

The Partition function returns a string that represents the calculated range that contains a number.

 Public Sub SaveSetting(ByVal AppName As String, _   ByVal Section As String, ByVal Key As String, ByVal Setting As String) 

The SaveSetting function sets a key value in the application's section in the Windows registry.

 Public Function Shell(ByVal Pathname As String, _   Optional ByVal Style As AppWinStyle = AppWinStyle.MinimizedFocus, _   Optional ByVal Wait As Boolean = False, _   Optional ByVal Timeout As Integer = -1) As Integer 

The Shell function starts a new process and returns the new process's ID, if it is still running.

 Public Function Switch(ByVal ParamArray VarExpr() As Object) As Object 

The Switch function returns the first parameter in the parameter array that evaluates to True . The parameter array must contain a set of paired values: The first value specifies the True / False value, and the second value is the value to return if the first value is True .

 <  Day Day Up  >  


The Visual Basic .NET Programming Language
The Visual Basic .NET Programming Language
ISBN: 0321169514
EAN: 2147483647
Year: 2004
Pages: 173
Authors: Paul Vick

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net