我想关闭ListBox中选定的TCP连接。
我尝试了这段代码,但它无效:
Public users_connection(999)
Public active_connections As Integer
' When a new client connect to the server
'...
Dim Stream As NetworkStream = client.GetStream()
active_connections += 1
users_connection(active_connections) = stream
'Close the connection
users_connection(ListBox1.SelectedIndex).Close()
当我尝试在ListBox中关闭所选连接时,会出现此错误:
System.NullReferenceException:'对象变量或未设置块变量。'