Dave Kimble
Member
- Joined
- Nov 20, 2012
- Messages
- 8
- Programming Experience
- 10+
Due to the constraints forced upon me by the structure of OOP programs
and the constraints of VB.NET's scoping of variables,
problems with variables' scope are getting in the way of me doing any work.
I can appreciate that if you have many people writing different parts of the same program,
then scoping the variable might avoid name clashes, but is there any way of switching scoping off when there is only one person writing the whole thing ?
Alternatively, is there a syntax that makes all variables accessible for everywhere?
Specifically, this doesn't work - the socket opened has port=0 :
and this doesn't even compile :
and this doesn't allow other subs to access server :
and the constraints of VB.NET's scoping of variables,
problems with variables' scope are getting in the way of me doing any work.
I can appreciate that if you have many people writing different parts of the same program,
then scoping the variable might avoid name clashes, but is there any way of switching scoping off when there is only one person writing the whole thing ?
Alternatively, is there a syntax that makes all variables accessible for everywhere?
Specifically, this doesn't work - the socket opened has port=0 :
VB.NET:
Public Class insserver
Public Shared port As Integer
Public Shared server As New System.Net.Sockets.TcpListener(System.Net.IPAddress.Parse("127.0.0.1"), port)
Private Sub doConfig()
port = 'something
End Sub
Private Sub openSocket()
server.Start()
End Sub
End Class
and this doesn't even compile :
VB.NET:
Public Class insserver
Public Shared port As Integer
Private Sub doConfig()
port = 'something
End Sub
Private Sub openSocket()
Public Shared server As New System.Net.Sockets.TcpListener(System.Net.IPAddress.Parse("127.0.0.1"), port)
server.Start()
End Sub
End Class
and this doesn't allow other subs to access server :
VB.NET:
Public Class insserver
Public Shared port As Integer
Private Sub doConfig()
port = 'something
End Sub
Private Sub openSocket()
Dim server As New System.Net.Sockets.TcpListener(System.Net.IPAddress.Parse("127.0.0.1"), port)
server.Start()
End Sub
End Class