Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating an Inputbox in C# using forms

Tags:

c#

forms

winforms

Hello I'm currently creating an application which has the need to add server IP addresses to it, as there is no InputBox function in C# I'm trying to complete this using forms, but am very new to the language so not 100% as to what I should do.

At the moment I have my main form and a form which will act as my inputbox which wants to hide on load. Then when the user clicks on the add IP Address on the main form I wish to open up the secondary form and return the IP address entered into a text box on the secondary form.

So how would I go about doing this? Or is there any better ways to achieve similar results?

like image 708
manemawanna Avatar asked Jul 18 '09 10:07

manemawanna


People also ask

What is an InputBox?

An input box is a specially designed dialog box that allows the programmer to request a value from the user and use that value as necessary. An input box displays a title, a message to indicate the requested value, a text box for the user, and two buttons: OK and Cancel.

What is InputBox C#?

Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns a string containing the contents of the text box. Syntax. VB. InputBox(prompt[, title] [, default] [, xpos] [, ypos] [, helpfile, context])

What is the use of InputBox () and Msgbox ()?

In this example, the InputBox function has one argument, a string that is used to prompt the user. The function returns whatever the user enters. (If the user clicks on the cancel button, a string of length zero is returned).

How do I use InputBox in Visual Basic?

The InputBox function prompts the users to enter values. After entering the values, if the user clicks the OK button or presses ENTER on the keyboard, the InputBox function will return the text in the text box. If the user clicks the Cancel button, the function will return an empty string ("").


1 Answers

You could just use the VB InputBox...

  1. Add reference to Microsoft.VisualBasic
  2. string result = Microsoft.VisualBasic.Interaction.InputBox("Title","text", "", 10, 20);
like image 139
ChuckB Avatar answered Oct 13 '22 08:10

ChuckB