Given the number of times I have come across this question and have not found a clear or direct answer, I am going to formalize it here.
What is the InputBox equivalent of vb.net
or VBA
in C#
?
Given the number of times I have come across this question and have not found a clear or direct answer, I am going to formalize it here.
What is the InputBox equivalent of vb.net
or VBA
in C#
?
To get access to
Inputbox
it, you must make a bridge with the references of the controls,VisualBasic
for this you must follow the following steps.In the solutions explorer we look for the section
Referencias
, we right-click and click onAgregar referencia...
Once inside we filter by
visual
,microsoft.visualbasic
,VisualBasic
, etc... and check the reference calledMicrosoft.VisualBasic
We declare the reference entering
using Microsoft.VisualBasic;
at the beginning of our codeWe call the control inside the function
Interaction.InputBox();
and assign the parameters it asks for, in the image below I put an example of the parameters it indicates, although the oneintellisense
from Visual studio helps a lotThere is no equivalent
InputBox [C#]
but if there is the possibility of creating the form dynamically using code and encapsulating everything in a class
create a class and put this code inside
so you just do