Results 1 to 6 of 6

Thread: [RESOLVED] C# equivalent of InputBox

  1. #1

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Resolved [RESOLVED] C# equivalent of InputBox

    My VB code would be:

    TotPmts = Cint(InputBox("How many monthly paymwents will you make?"))

    What would be the C# equivalent of that? Unfortunately my "Visual C# 20005" manual only uses console apps as their illustrations. I don't think "Readline" is what I am looking for.
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  2. #2

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: C# equivalent of InputBox

    OK. I found a sample showing the creation of a form for user input. I created it (called InputBox). It has a field called txtUserInput on it.

    My forms invokes it using the following code:

    InputBox ib = new InputBox();
    ib.Text = "What is your monthly payment?";
    ib.ShowDialog();
    string result = ib.txtUserInput;
    ib.Dispose();

    I get this error message (highlighting the ib.txtUserInput statement):

    'TVAL.InputBox.txtUserInput' is inaccessible due to its protection level I:\VB NET Source Code\C#\TVAL\TVAL\TVAL\Form1.cs 1213 32 TVAL
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  3. #3
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: C# equivalent of InputBox

    You are trying to put the actual TextBox control into a string.
    You want to put its Text into the string.

    Code:
    string result = ib.txtUserInput.Text;

  4. #4

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: C# equivalent of InputBox

    I got it figured out. I missed a "get" statement.
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  5. #5
    New Member
    Join Date
    Jul 2007
    Posts
    1

    Re: [RESOLVED] C# equivalent of InputBox

    you actually can use a real input box in C#
    add a reference to Microsoft.VisualBasic
    Microsoft.VisualBasic.Interaction.InputBox("prompt","title","default response",xPos,yPos)

  6. #6

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: [RESOLVED] C# equivalent of InputBox

    If I am going to continue using "VB" code inserts, I might as well continue using VB.
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width