Click here to Skip to main content
15,920,650 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
Tried Googling this came up with Various ways. Not however a method I have used in the past.
using Microsoft.VisualBasic;

I think then something like
string StringInput;
StringInput = VisualBasic.InputBox(InputString,"Title","", 100,100);

This does not seem to work, I'm pretty sure I did it Vis Studio 2008 with C#.For reason I don't fully under stand I have to use 2005 and would like to do something simplier...

What I have tried:

Google, Hunting my code, there must be a simple way of doing it?
Updated 25-Mar-23 21:02pm
Graeme_Grant 25-Mar-23 23:01pm    
Simpler than 1 line of code????
[no name] 26-Mar-23 0:52am    
If it's a "C# project", by default, you have to add references to VB libs yourself.

Given you want to do it in .NET Framework, you possibly can try below:

1. Add a reference to Microsoft.VisualBasic
2. Refer namespace Microsoft.VisualBasic.Interaction (InputBox is in this namespace)
using Microsoft.VisualBasic;
// OR using Microsoft.VisualBasic.Interaction;
3. Try something like below:
// Only the first argument (prompt) is mandatory
string input = Interaction.InputBox("Prompt", "Title", "Default", x_coordinate, y_coordinate);

As I was shared, this might not work in .NET Core though.
Share this answer
glennPattonWork3 26-Mar-23 6:39am    
Works, Thank You!
It may be simpler, but it's not particularly efficient to drag the whole of the Microsoft.VisualBasic assembly into your app just to use a feature that you could replicate yourself in a couple of minutes!

Instead, I'd consider creating your own control library in a separate assembly, and put your own InputBox in there if you need one: a simple form with Prompt, Title, and Value properties that allows the user to enter a string is the work of minutes to create, and you can personalise it in so many ways!

That way, you start building a library of your own "look and feel" stuff for your apps instead of adding a lot of junk along with a single outdated component you want.
Share this answer
This is a nice CodeProject alternative: Content-driven Input Dialog[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900