Look at your code:
Dim lbResults As ListBox
Dim Results As String
Dim strName As String 'declare Hello and txtName as string in order to simplify code
strName = "Hello " & txtName.Text
lbResults.Items.Add(Results)
You declare variables
lbResults
and
Results
, but at no point do you give them a value. So when you get to this line:
lbResults.Items.Add(Results)
both lbResults and Results are
Nothing
and you get a compilation error that you are using an uninitialised value. That's a good thing - because if you didn't then when you ran the code you would get a "null reference error" because there is no ListBox in
lbResults
to have an
Items
property!
Probably, you don't want to declare
lbResults
in that method at all - it will mask the one that is on your form so your user will not see any results anyway. So remove the declaration line and see if that error goes away. If it is replaced by "undefined variable" errors, then you need to put it back, create an instance, and manually add it to your form in order for the user to see anything.
You can also need to add each
Results
value to your ListBox when you create the Results string - or it won't be seen either.
Like this:
If radCompliment.Checked = True Then
Results = strName & "You are FABULOUS"
lbResults.Items.Add(Results)
Else
MessageBox.Show("Please input information")
End If
(but you'll need it in every condition as well).