Solved

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

Posted on 2011-09-21
8
1,106 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
8 Comments
 
LVL 13

Expert Comment

by:jonnidip
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Author Comment

by:peterkiers
Comment Utility
But I have read on several pages that it is possible!

Peter
0
 
LVL 1

Author Comment

by:peterkiers
Comment Utility
Oke  I make my own custom form.

Peter
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
>>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 85

Expert Comment

by:Mike Tomlinson
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now