For developers with VB background InputBox may not be a new thing but for C# and VB.NET programmers developing Windows Forms (OR WinForms) this may seem alien. The reason this is not familiar to the WinForms developers is that it is not under the namespace "System.Windows.Forms" where all the other WinForms controls are available. InputBox is actually a method that can be used to collect some information from user. A screenshot of a input box is shown below:
The method signature for InputBox looks as follows:
public static string InputBox( string Prompt, string Title, string DefaultResponse, int XPos, int YPos )
More information on the input parameters can be found here.
A sample usage in C# can be as follows:
string userInput = Microsoft.VisualBasic.Interaction.InputBox("Enter your name", "My Title", "default", 0, 0);
Note: If the user clicks cancel string.Empty is returned.


0 comments:
Post a Comment