unused local variable name

the_curious

New member
Joined
Jun 1, 2008
Messages
2
Programming Experience
1-3
hello everybody,

im new here :D

anyways, ive got a lot of experience in actionscript and PHP.

just trying to figure out this vb.net :confused:

VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim strContents As String
        Dim objReader As System.IO.StreamReader
        Open.ShowDialog()
        filepath.Text = Open.SelectedPath
    End Sub

no matter where i try to declare variables, the name gets underlined and it says "unused local variable:varname"

and i really can't figure out why. im trying to read a text file, but can't even declare variables.

Here is the whole program structure

VB.NET:
Public Class DeskTop

//vars




    Friend Sub Set(ByVal imgage As Image)
//code
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     //code
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        //code
    End Sub

    Private Sub DeskTop_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

any help greatly appreciated!
 
"unused local variable:varname" isn't an error, it's a warning. It's just the compiler telling you the variable "strContents" is never read from anywhere. Just do something with your variables and the warning will dissapear...
 
Using the help system will quickly tell you what keywords are, but a structured VB.Net beginner book or two is recommended for start learning.
 
Subs are functions that return nothing. As for classes, the topic is too long to explain here. Search for object oriented programming and similiar buzz words and you should find the info you need.

okay i feel retarded

Don't worry about it, we all get to that part of the job a few times ;)
 
"unused local variable:varname" isn't an error, it's a warning. It's just the compiler telling you the variable "strContents" is never read from anywhere. Just do something with your variables and the warning will dissapear...

note: assigning to a variable can be a use of it too.. in c# i then see "x Is assigned a value but the value is never used"
 
Back
Top