Inputbox in VB.NET?

J. Scott Elblein

Well-known member
Joined
Dec 14, 2006
Messages
166
Location
Chicago
Programming Experience
10+
I just discovered that pure .net doesn't have an Inputbox? I want to remove the vb namespace and go pure .net, and the thing I like about the old Inputbox is how quick and easy it is. Is there some version in .net that I am missing?

TIA
 
I don't see anything wrong if you just use the InputBox although it belongs to Microsoft.Visualbasic namespace. However youc an always make your own adapting common WinForm. VS 2005 even exposes a premade Dialog form ... just drop textBox control and voila.

:)
 
You can't remove the implicit reference to Microsoft.VisualBasic.dll because that's where all the new stuff and the VB runtime is, but you can remove the namespace to avoid unintended use of runtime functions. So without the imports you qualify the object fully:
VB.NET:
Dim s As String = Microsoft.VisualBasic.InputBox("input:")
 
Hi

Since it can't be removed, is there any reason for using the .net way for some things over older vb ways? For example: using string.split over vb6 split. Or using string.contains over instr(), etc.? Strictly performance?

For some reason I was under the assumption that everyone talks about trying to avoid all older vb code, having something to do with portability, (or something like that). So I was trying to remove 100% of all old vb code.

Thanks for the info/help guys. This is a very helpful forum for learning newbs like moi. :)
 
There exist an MS article recommending use of all VB language features when coding VB.Net, but many (me included) thinks Framework classes is better OOP (including readability) than the runtime functions. I am also one of those that like and use the new MY features (sometimes), but that is not portable either, it's VB.Net only. Porting applications between different .Net Framework languages isn't really a big issue in my opinion, the issue is more of awareness and porting .Net developers between the languages. That means if you are aware about these matters you can with more ease transition between coding C# and VB.Net and other .Net languages, and you will probably then choose the better coding style for yourself. With the inputbox for example there isn't a C# alternative or native .Net, but as mentalhard said it's a ClickTwice operation to create a basic one yourself.
 
I wonder why MS chose to exclude an inputbox in the .NET native classes, so VB'er as well as C#'er could have one?

So what in your opinion is better, do as Mentalhard said and make the 2-click version, or just use the older inputbox?
 
If i may; It depends on your needs above all. If you just need to prompt the users for some enter then why overcomplicating? Go for the old and GOOD InputBox :)
 
Back
Top