However, the If statement doesn't loop through any statements. The If statement is probably the most common control flow element. In this article, we'll show you the syntax for these statement using Visual Basic and what you can do with them to control logic flow throughout your programs. These statements are a part of any programming language, and they are used often to control output and input depending on a defined set of criteria. MessageBox.Show("Thank you " + txtName.Text + " from " + txtOrg.The If and Select statements control Visual Basic logic flow. Private Sub btnMessage_Click(sender As Object, e As EventArgs) _ Private Sub Form1_Load(sender As Object, e As EventArgs) _
Set its name to btnMessage and its text property to 'Send Message'.Ĭlick the button to add the Click event in the code window and add the following code.
Take the following steps −ĭrag and drop three Label controls and three TextBox controls on the form.Ĭhange the texts on the labels to: Name, Organization and Comments, respectively.Ĭhange the names of the text boxes to txtName, txtOrg and txtComment, respectively.ĭrag and drop a button control on the form. In this example, we create three text boxes and use the Click event of a button to display the entered text using a message box. Occurs when the TextAlign property value changes. Occurs when the control is double-clicked. The following are some of the commonly used events of the Text control − Sr.No. Undoes the last edit operation in the text box. Returns a string that represents the TextBoxBase control. Resets the Text property to its default value. Sets the selected text to the specified text without clearing the undo buffer.
Replaces the current selection in the text box with the contents of the Clipboard. Moves the current selection in the text box to the Clipboard. The following are some of the commonly used methods of the TextBox control − Sr.No.Īppends text to the current text of a text box.Ĭlears all text from the text box control.Ĭopies the current selection in the text box to the Clipboard. Indicates whether a multiline text box control automatically wraps words to the beginning of the next line when necessary. Gets or sets how text is aligned in a TextBox control. Gets or sets the current text in the TextBox. Gets or sets the tab order of the control within its container. Gets or sets which scroll bars should appear in a multiline TextBox control. Gets or sets a value indicating whether text in the text box is read-only.
Gets or sets the character used to mask characters of a password in a single-line TextBox control. Gets or sets a value indicating whether this is a multiline TextBox control. Gets or sets the lines of text in a text box control. Gets or sets the foreground color of the control. Gets or sets the height of the font of the control. Gets or sets the font of the text displayed by the control. Gets or sets whether the TextBox control modifies the case of characters as they are typed. Gets or sets a value specifying the source of complete strings used for automatic completion. Gets or sets an option that controls how automatic completion works for the TextBox.
Gets or sets a custom to use when the AutoCompleteSourceproperty is set to CustomSource. Gets or sets a value indicating whether pressing ENTER in a multiline TextBox control creates a new line of text in the control or activates the default button for the form. The following are some of the commonly used properties of the TextBox control − Sr.No. Let's create a text box by dragging a Text Box control from the Toolbox and dropping it on the form. By default, it takes a single line of text, however, you can make it accept multiple texts and even add scroll bars to it. Text box controls allow entering text on a form at runtime.