我用vb做了一個服務器客戶端一對多連接的軟件,服務器裡面是動態添加sock picture和label。但是實現的時候只有sock和picture會動態添加,label添加不了,為什麼啊
Private Sub Listener_ConnectionRequest(ByVal requestID As Long)
Dim SockIndex As Integer: SockIndex = 8888
Dim i As Integer
For i = 0 To sock.UBound
If sock(i).State = 0 Then SockIndex = i
Next
If SockIndex = 8888 Then
Load Picture1(Picture1.UBound + 1)
Load Label1(Label1.UBound + 1)
Load sock(sock.UBound + 1)
SockIndex = Label1.UBound
SockIndex = Picture1.UBound
SockIndex = sock.UBound
Picture1(Picture1.UBound).Visible = True
Picture1(Picture1.UBound).Left = i * 3000
Label1(Label1.UBound).Visible = True
Label1(Label1.UBound).Left = i * 3000
End If
sock(SockIndex).Accept (requestID)
Picture1(SockIndex).BackColor = &HFF00&
Label1(SockIndex).Caption = sock(SockIndex).RemoteHostIP
End Sub
這是sock連接的代碼,我覺得是這邊出了問題
label也是可以的,看下寬度、zindex順序。調試下就知道了。