|
By: Paul S Cilwa |
Posted: 4/10/2026 |
|
Page Views: 25 |
| Hashtags: #Namtira #VisualBasic #VBNET #ClassLibrary #NamtiraLib #SuperMessages #MessageBox #InputBox |
| Simplified wrappers around the standard MessageBox and InputBox dialogs. |
| Estimated reading time: 2 minute(s) (288 words) |
| Module SuperMessages |
| Member | Parameters | Example |
| AskBox | Text As String, Title (opt), IconChoice (opt) | If AskBox("Delete?") Then ... |
| MsgBox | Text As String, Title (opt), Buttons (opt), IconChoice (opt) | MsgBox("Done!", "Status") |
| InputBox | Text As String, Title (opt), Buttons (opt) | Dim name = InputBox("Your name?") |
AskBox
Presents a Yes/No dialog and returns True if the user
clicks Yes. The default button is No, so pressing Enter without
thinking won't accidentally confirm a destructive action. The icon
defaults to MessageBoxIcon.Question.
Public Module SuperMessages
Public Function AskBox(Text As String,
Optional Title As String = "",
Optional IconChoice As MessageBoxIcon = MessageBoxIcon.Question) As Boolean
Return (MessageBox.Show(Text, Title,
MessageBoxButtons.YesNo, IconChoice,
MessageBoxDefaultButton.Button2) = DialogResult.Yes)
End Function
End Module
MsgBox
A fire-and-forget notification. Defaults to an OK button and the
Information icon. The optional Buttons and
IconChoice parameters let you override these when needed.
Public Sub MsgBox(Text As String,
Optional Title As String = "",
Optional Buttons As MessageBoxButtons = MessageBoxButtons.OK,
Optional IconChoice As MessageBoxIcon = MessageBoxIcon.Information)
MessageBox.Show(Text, Title, Buttons, IconChoice)
End Sub
InputBox
Prompts the user for a line of text, delegating to the classic
Microsoft.VisualBasic.Interaction.InputBox under the
hood. Returns the entered string, or an empty string if the user
cancels.
Public Function InputBox(Text As String,
Optional Title As String = "",
Optional Buttons As MessageBoxButtons = MessageBoxButtons.OKCancel) As String
Return Microsoft.VisualBasic.Interaction.InputBox(Text, Title)
End Function