Input Box function

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 4446 Views - Last Post: 05 May 2010 - 02:02 PM Rate Topic: -----

#1 PNWtroop  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 01-April 10

Input Box function

Posted 04 May 2010 - 07:51 PM

I am going through a tutorial in our textbook for C# and it has a section for Input Box function.

I saw in another post that C# does not have the Input Box function. Is this no longer availbale in VS 2008 but would have been available in VS 2005. the textbook references VS 2005 only.
Is This A Good Question/Topic? 0
  • +

Replies To: Input Box function

#2 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1004
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: Input Box function

Posted 05 May 2010 - 12:18 AM

I would assume that an Input Box is just a TextBox control??
Was This Post Helpful? 0
  • +
  • -

#3 batesy3k  Icon User is offline

  • D.I.C Regular

Reputation: 41
  • View blog
  • Posts: 299
  • Joined: 10-September 09

Re: Input Box function

Posted 05 May 2010 - 01:07 AM

Or does he mean a messagebox style popup with a space to enter text?
Was This Post Helpful? 0
  • +
  • -

#4 FlashM  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 382
  • View blog
  • Posts: 1,195
  • Joined: 03-December 09

Re: Input Box function

Posted 05 May 2010 - 01:08 AM

Actually not... InputBox is a MessageBox like control. It displays a message, has Yes and No buttons and also has a textbox in which you can enter some value and confirm it. Unfortunately, only VB.NET has an inputbox. In C#, you will have to make your own.

This post has been edited by FlashM: 05 May 2010 - 01:08 AM

Was This Post Helpful? 2
  • +
  • -

#5 PNWtroop  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 01-April 10

Re: Input Box function

Posted 05 May 2010 - 01:15 PM

That is what I thought. The textbook I am using is Starting Out with C# and they have a section for the Input Box function but it was nowhere to be found like the MessageBox function. The author covered Input Box and List Box function in the same section. I tried to enter the code like the author showed and got an error saying InputBox() did not exist.

I just wanted to confirm this. Thanks.
Was This Post Helpful? 0
  • +
  • -

#6 FlashM  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 382
  • View blog
  • Posts: 1,195
  • Joined: 03-December 09

Re: Input Box function

Posted 05 May 2010 - 01:23 PM

There are number of functions and features provided in VB.NET that you can't find in C#.

For example: there is no IsNumeric(object value) IsDate(object value) or similar functions in C#. In all this cases you will have to use int.TryParse or double.TryParse or float.TryParse or DateTime.TryParse, etc...

Anyway, what kind of book are you reading? You really should get something more up-to-date :-)
Was This Post Helpful? 0
  • +
  • -

#7 MentalFloss  Icon User is offline

  • "ADDICTED"[2:5]
  • member icon

Reputation: 526
  • View blog
  • Posts: 1,397
  • Joined: 02-September 09

Re: Input Box function

Posted 05 May 2010 - 01:38 PM

So, just make a windows form with 2 buttons. Set button1 to DialogResult.OK and set button2 to DialogResult.Cancel. Then add a textbox. Then ShowDialog() and retrieve the DialogResult.

That would be a roll-your-own inputbox.

EDIT: Err.. you'll need a property in the form that stores the text entry in order to get it out.

Attached File(s)


This post has been edited by MentalFloss: 05 May 2010 - 01:46 PM

Was This Post Helpful? 2
  • +
  • -

#8 Momerath  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1012
  • View blog
  • Posts: 2,444
  • Joined: 04-October 09

Re: Input Box function

Posted 05 May 2010 - 01:43 PM

Silly people, this is .NET! Just add a reference to Microsoft.VisualBasic, and it is available for use!

using Microsoft.VisualBasic;

... stuff left out

     Interaction.InputBox("Prompt", "Title", "Default Text", xpos, ypos);


Was This Post Helpful? 1
  • +
  • -

#9 MentalFloss  Icon User is offline

  • "ADDICTED"[2:5]
  • member icon

Reputation: 526
  • View blog
  • Posts: 1,397
  • Joined: 02-September 09

Re: Input Box function

Posted 05 May 2010 - 01:47 PM

Quote

Silly people, this is .NET! Just add a reference to Microsoft.VisualBasic, and it is available for use!


Is this good practice though?

Excusing the merits of even using this InputBox concept....
Was This Post Helpful? 0
  • +
  • -

#10 FlashM  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 382
  • View blog
  • Posts: 1,195
  • Joined: 03-December 09

Re: Input Box function

Posted 05 May 2010 - 01:51 PM

Momerath: Actually the thing you suggested is true, but this is known as bad coding style... Professional software developer would never do this...

And this is a bad practice because your application would then depend on another DLL file which is totally unnecessary.

This post has been edited by FlashM: 05 May 2010 - 01:51 PM

Was This Post Helpful? 0
  • +
  • -

#11 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Input Box function

Posted 05 May 2010 - 01:52 PM

View PostMomerath, on 05 May 2010 - 11:43 AM, said:

Silly people, this is .NET! Just add a reference to Microsoft.VisualBasic, and it is available for use!

using Microsoft.VisualBasic;

... stuff left out

     Interaction.InputBox("Prompt", "Title", "Default Text", xpos, ypos);



Horrible advice! There is never a good reason for using the Microsoft.VisualBasic Namespace in C#, and I mean never
Was This Post Helpful? 1
  • +
  • -

#12 Momerath  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1012
  • View blog
  • Posts: 2,444
  • Joined: 04-October 09

Re: Input Box function

Posted 05 May 2010 - 01:53 PM

View PostFlashM, on 05 May 2010 - 11:51 AM, said:

Momerath: Actually the thing you suggested is true, but this is known as bad coding style... Professional software developer would never do this...

And this is a bad practice because your application would then depend on another DLL file that is totally unnecessary.

Disregarding the merits of InputBox itself, I have to disagree with you. If you have .NET installed on your system, the DLL is there. Depending on DLLs does not make something a bad practice.

And as a professional software developer, I've depended on DLLs for a long time now.
Was This Post Helpful? 0
  • +
  • -

#13 FlashM  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 382
  • View blog
  • Posts: 1,195
  • Joined: 03-December 09

Re: Input Box function

Posted 05 May 2010 - 01:57 PM

I guess you haven't learned from the best... :-)
Was This Post Helpful? 0
  • +
  • -

#14 Momerath  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1012
  • View blog
  • Posts: 2,444
  • Joined: 04-October 09

Re: Input Box function

Posted 05 May 2010 - 01:58 PM

View PostPsychoCoder, on 05 May 2010 - 11:52 AM, said:

There is never a good reason for using the Microsoft.VisualBasic Namespace in C#, and I mean never

Now that we know your opinion, give reasons why please.

How is depending on a library of methods any different if it was called VisualBasic, or MyInputBox?

View PostFlashM, on 05 May 2010 - 11:57 AM, said:

I guess you haven't learned from the best... :-)

Please tell me these 'best' that say not to rely on DLLs?
Was This Post Helpful? 0
  • +
  • -

#15 MentalFloss  Icon User is offline

  • "ADDICTED"[2:5]
  • member icon

Reputation: 526
  • View blog
  • Posts: 1,397
  • Joined: 02-September 09

Re: Input Box function

Posted 05 May 2010 - 02:00 PM

I think the real question is what is available in the Microsoft.VisualBasic namespace that's actually useful (I hardly think that InputBox is). Otherwise, this argument is just pissing in the wind.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2