Hi folks.
I have a button, textbox, and some radio buttons inside a groupbox. I enter text into the textbox, and select a radio button, and then click the button. The program stores the text that was entered, as well as the name of the radiobutton in a file. Why am I getting the "variable used before it has been assigned a value' for the freq variable? The value had already been assigned in the For Each loop?
Thanks in advance.
EDIT: I am also unsuccessfully trying to add a space between the text and the name of the radiobutton when the string is written to the file.
Code:Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim rButton As RadioButton Dim freq As String Dim NewEvent As String For Each rButton In GroupBox1.Controls.OfType(Of RadioButton)() If rButton.checked Then freq = rButton.Name End If Next NewEvent = txtNewEventAdd.Text & freq My.Computer.FileSystem.WriteAllText("events.txt", NewEvent, True) txtEventDisplay.Text = My.Computer.FileSystem.ReadAllText("events.txt") End Sub End Class




Reply With Quote