15
using Microsoft.VisualBasic;

Microsoft.VisualBasic.Interaction.InputBox("Favourite RPG?", "Game", "Cool!");

So what this does is basically ask the user their favourite RPG. Then it displays the default value. I know this is a small example but my program will not run because I'm getting this error:

The type or namespace name 'Interaction' does not exist in the namespace 'Microsoft.VisualBasic' (are you missing an assembly reference?)

Originally I found this here

3 Answers 3

27

In addition to using Microsoft.VisualBasic; add the reference, too. Here's a visual answer:

enter image description here

Then

enter image description here

16

You need to add a reference to the Microsoft.VisualBasic.dll

The using statement you have is not a reference. It's merely a shortcut so you don't have to type the full namespace every time you want to access a member inside it.

3
  • How do you add reference? I never did this before.
    – puretppc
    Jan 19, 2014 at 1:41
  • 3
    Right click on your project file, go to add reference or add then reference depending on what version of VS you're using
    – Kenneth
    Jan 19, 2014 at 1:42
  • 1
    Alright thanks :) I'll give this to you since you were the first. +1 to the rest who have helped :)
    – puretppc
    Jan 19, 2014 at 1:56
6

Right click your References in the Solution Explorer click Add Reference,then search for Microsoft.VisualBasic and add it to your references.

For more information see this documentation: How to: Add or Remove References By Using the Add Reference Dialog Box

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.