Question trouble understanding some of the errors I receive

ingentr

New member
Joined
Jun 26, 2011
Messages
2
Programming Experience
Beginner
I am in a vb.net class and I'm having trouble understanding some of the errors I receive when programming. The class is online so I don't have the interaction with a professor I may have in a traditional setting. When I code in the examples in the book to try to learn from it, they are riddled with errors. What am I missing? For example, and this applies to what I'm working on now, I create a button and a listbox and code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a As Double
        Dim b As Double = 3
        stResults.Items.Clear()
        stResults.Items.Add(a)
        stResults.Items.Add(b)
        a = 5
        stResults.Items.Add(a * (2 + b))

    End Sub

End Class
The result should be: 0 3 25 each on a separate line. However, I receive errors that say, 'tResults' is not declared, Syntax error, 'Label 1' is already defined. The auto-error correction option just complicates it. What am I missing?? What do I need to include to make this an error-free program?? Thank you for your help. Private
 
Last edited by a moderator:
The code you posted doesn't include 'tResults' or 'Label 1' so it's hard to say what the issues are. Are you sure those are the actual error messages generated by that code?
 
Thanks for the reply. Well, that was the short version. I can try to copy and paste an example of each error. Keep in mind, the book says, 1stResults.Items.Add(a). The #1 was also generating an error so I tried to remove it. That is how I ended up with just the stResult... Well, I guess there are 4 instances of this one error in the above example.

Error 1 'stResults' is not declared. It may be inaccessible due to its protection level. C:\Documents and Settings\Me\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.vb 6 9 WindowsApplication1

If I type what the book has and make them 1stResults.Items.Add...I also receive

Error 1 Syntax error. C:\Documents and Settings\Me\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.vb 6 9 WindowsApplication1

Error 5 Label '1' is already defined in the current method/multiline lambda. C:\Documents and Settings\Me\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.vb 10 9 WindowsApplication1

and

Error 2 'tResults' is not declared. It may be inaccessible due to its protection level. C:\Documents and Settings\Me\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.vb 6 11 WindowsApplication1
 
In VB.NET, all identifiers (e.g. variables, properties, methods, types) must start with either a letter or an underscore. '1stResults' would indeed be an invalid name. If that is supposed to be a ListBox then the name you use in code will be dictated by the name you give the control when you add it to the form in the designer. Did you add a ListBox to your form? What did you name it? That's the name you use in code to refer to it.
 
Back
Top