How to Clear a Radio Button on Visual Basic

Radio buttons are a common type of graphic user interface (GUI) component that allow one item out of a list of items to be selected in a program. The buttons generally appear as a series of while circles, with the selected item filled in with a dot. In most applications, one option of the radio button set will always be selected, but it might be necessary to clear them all.

Coworking station. Modern business loft
credit: littlehenrabi/iStock/Getty Images

Step

Create a new project by selecting “New Project” from the File menu. Press "OK" or "Next" in any dialogue boxes that come up, as the default options are all we need to select. You should see a blank form. Go to the components list on the left-hand side of your screen and find the entry for the radio button.

Step

Drag three radio buttons onto your form and place them wherever you like. If you like, you can press the "Compile and Run" button now (it appears as a green arrow on the toolbar) and test the radio buttons. You can do this by clicking each radio button in your window to ensure that only one can be selected at any given time.

Step

Find the button in the "Components" list and drag it onto the form. While the button is still selected, go to the "Properties" window on the bottom right of your screen and change its text property to read: “Clear Radio Buttons.”

Step

Double click the button. This will instantly switch you from the GUI design interface where you lay out components to the source code editor, which lets you assign programming to the components. It will also create an event function for the button. This section of code will run whenever the button is pressed by the user. By default, it will have a name like this:

Step

Handles Button1.Click ... End Sub

Step

However, it might look slightly different depending on your version of Visual Basic.

Step

Within the "Button1_Click" function, add the following code to clear all the radio boxes:

Step

Run your program again and select one of the radio components. When you are ready, click the "Clear" button and the radio buttons will be cleared.