Microsoft.VisualBasic.Interaction
The Interaction
class provides a set of methods that allow
communication between the user and the program, such as displaying messages
and prompting for input. It mirrors Visual Basic's legacy Interaction module
for .NET developers.
Methods
Name | Signature | Description |
---|---|---|
InputBox | InputBox(prompt As String, [title As String], [defaultResponse As String]) As String | Displays a prompt in a dialog box, waits for the user to input text, and returns the value. |
MsgBox | MsgBox(prompt As String, [buttons As MsgBoxStyle], [title As String]) As MsgBoxResult | Shows a message box with customizable buttons and icon. |
AppActivate | AppActivate(titleOrProcessId As Object) | Activates an application window by title or process ID. |
Properties
No public static properties are defined for this class.
Example
// Prompt the user for a name and greet them
Dim name As String
name = Interaction.InputBox("Enter your name:", "Greeting")
If name <> "" Then
Interaction.MsgBox("Hello, " & name & "!", MsgBoxStyle.Information, "Welcome")
End If
Remarks
The Interaction
class is primarily retained for compatibility
with older Visual Basic code. New .NET applications typically use
System.Windows.Forms
or Microsoft.WinUI
for UI
interactions.