Solved

The name 'InputBox' does not exist in the current context

Posted on 2011-09-21
8
1,168 Views
Last Modified: 2013-12-17
Hi,

I have this error: The name 'InputBox' does not exist in the current context.
By making this methode:

        private void cmuTitle_Click(object sender, EventArgs e)
        {
            string value = "";
            if (InputBox.Show("Set Note's title", "title:", ref value) == DialogResult.OK)
            {
                gpclStNotes.Text = value;
            }
        }

Who can help me?

Peter
0
Comment
Question by:peterkiers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 13

Expert Comment

by:jonnidip
ID: 36573658
Maybe you are missing a "using".
Try to right-click over "InputBox" and see if you can see "Resolve"...
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36573695
I have looked up on the internet and found this:
using Microsoft.VisualBasic;
But still got the error.

P.
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36573704
I even did this:

1>Right click on project in Solution Explorer and Click on Add Reference

2>Select Microsoft.VisualBasic

3>Click Ok

4. using Microsoft.VisualBasic
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 36573868
InputBox is visual basic code.  There isn't an equivalent in C# as far as I know.  :-(

You have to make your own custom form.
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36573902
But I have read on several pages that it is possible!

Peter
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36573911
Oke  I make my own custom form.

Peter
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 36574228
>>But I have read on several pages that it is possible!

Are you following the instructions there exactly?  (They are in C# and not Visual Basic I hope).
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 36574303
The code you found is NOT using the VB.Net InputBox()...it must be a custom replacement.

The VB.Net InputBox() function:
http://msdn.microsoft.com/en-us/library/6z0ak68w(VS.90).aspx

...is just a wrapper for the legacy VB6 InputBox() function:
http://msdn.microsoft.com/en-us/library/aa445028(VS.60).aspx

Neither returns a DialogResult.  Instead, it returns the value entered into the box.  Hitting Cancel or the 'X' returns a blank string, and you can't differentiate whether the user cancelled the dialog or hit OK with no input.

InputBox() is part of Microsoft.VisualBasic, but is actually located in Microsoft.VisualBasic.Interaction.

Project --> Add Reference --> Microsoft.VisualBasic.
Add "using Microsoft.VisualBasic;".
Now qualify it with "Interaction".

Here's a simple example:



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualBasic;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string name = Interaction.InputBox("Name: ", "Please enter your name...");
            label1.Text = name;
        }

    }
}

Open in new window

0

Featured Post

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question