22-01-14, 04:14 AM
جرب التالي:
كود :
Private Sub ListBox1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDoubleClick
' MsgBox(ListBox1.Text)
dim stop as Boolean
For Each f As Form In Application.OpenForms
If Break(f) Then
f.Activate()
stop = true
Exit For
End If
Next
if stop then exit sub
Dim chat As New chat
Dim gip As New SqlCommand("select uname,myip from tusers where uname='" & ListBox1.Text & "'", conn)
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
Dim dr As SqlDataReader = gip.ExecuteReader
If dr.Read Then
Try
chat.frindname.Text = ListBox1.Text
frindip = dr.Item("myip")
chat.Show()
Catch ex As Exception
MsgBox("هذا العضو لم يسجل دخوله ليتم تحديث معلومات الاتصال به", MsgBoxStyle.Critical, "")
End Try
End If
End Sub
Private Function Break(form As Form) As Boolean
For Each ctrl As Control In form.Controls
If TypeOf ctrl Is Label AndAlso ctrl.Text = listBox1.Text Then
Return True
End If
Next
Return False
End Function