Microsoft's Visual Basic allows user input via the TextBox control, and the various properties of the control allow the programmer to make changes to the visual effects of the TextBox. Although there is no border-colour property for a TextBox control in Visual Basic, there is a way to accomplish the desired effect using the program's Power Pack RectangleShape control.
- Skill level:
- Moderately Easy
Other People Are Reading
Start Microsoft Visual Basic and click "New Project" on the Start page, then double-click on "Windows Forms Application" to open a new blank form.
Click on the "Toolbox" tab on the left of the Design window to open the Toolbox.
Double-click on the "Button" control twice to add two buttons to the form. Double-click on the "TextBox" control to add a TextBox to the form. Scroll down in the Toolbox to the "Power Pack" menu item and double-click on the "RectangleShape" control to add a rectangle to the form.
Click on the form to close the Toolbox and arrange the buttons on the form. Drag the TextBox to the middle of the form and drag the RectangleShape over the TextBox and align the two so that the RectangleShape displays on the border of the TextBox. This allows the RectangleShape to serve as the border for the TextBox.
Double-click on "Button1" to open the Code window and place the cursor in the "Button1_click" event procedure. Add the following code between the two lines:
RectangleShape1.BorderColor = Color.Red
This will cause the RectangleShape1 border to change to the colour red, which will give the appearance of a red border around the TextBox. Repeat this process for "Button2," changing the "Color.Red" to "Color.Green."
Click on the "Debug" menu item at the top of the screen and select the "Start Debugging" option. This will bring up your form in test mode. Click "Button1" and the border around the TextBox should turn red. Click "Button2" and the border around the TextBox should turn green.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for