[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.
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
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;
Re: C# equivalent of InputBox
I got it figured out. I missed a "get" statement.
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)
Re: [RESOLVED] C# equivalent of InputBox
If I am going to continue using "VB" code inserts, I might as well continue using VB.