Click here to Skip to main content
15,905,028 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Detect the file is opened or not? Pin
Christian Graus21-Feb-06 16:30
protectorChristian Graus21-Feb-06 16:30 
AnswerRe: Detect the file is opened or not? Pin
japel21-Feb-06 18:32
japel21-Feb-06 18:32 
QuestionWhat object is streamwriter located under? Pin
kenn_rosie21-Feb-06 13:00
kenn_rosie21-Feb-06 13:00 
AnswerRe: What object is streamwriter located under? Pin
progload21-Feb-06 13:37
progload21-Feb-06 13:37 
GeneralRe: What object is streamwriter located under? Pin
kenn_rosie21-Feb-06 13:49
kenn_rosie21-Feb-06 13:49 
GeneralRe: What object is streamwriter located under? Pin
progload21-Feb-06 14:36
progload21-Feb-06 14:36 
GeneralRe: What object is streamwriter located under? Pin
kenn_rosie21-Feb-06 14:51
kenn_rosie21-Feb-06 14:51 
QuestionServer & Client Pin
ADY00721-Feb-06 12:25
ADY00721-Feb-06 12:25 
Hi, I am programming a tcp messanger with ips. this is my coding for the server!

THE PROBLEM IS THAT WHEN I MAKE PORT 5000 OR ANY OTHER NUMBER IT CRASHES AND TELLS ME THAT IT MUST BE PERFORMED BY 1 TIME ONLY! SOCKETERROR
listener = New TcpListener(5000)
listener.Start()


THIS IS MY WHOLE CODING FOR THE SERVER
Imports System.Threading
Imports System.Net.Sockets
Imports System.IO
Imports System.Windows.Forms

Public Class frmServer
Inherits Form

Private connection As Socket
Private readThread As Thread
Private socketStream As NetworkStream
Private writer As BinaryWriter
Private reader As BinaryReader

Private Sub frmServer_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
System.Environment.Exit(System.Environment.ExitCode)
End Sub

Private Sub txtOut_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtOut.KeyDown

Try
If (e.KeyCode = Keys.Enter AndAlso Not connection Is Nothing) Then
writer.Write("Server>>> " & txtIn.Text)

txtOut.Text &= vbCrLf & "Server>>> " & txtIn.Text

If txtIn.Text = "Terminate" Then
connection.Close()
End If

txtIn.Clear()
End If

Catch ex As SocketException
txtOut.Text &= vbCrLf & "Error writing object"
End Try
End Sub

Public Sub RunServer()
Dim listener As TcpListener
Dim counter As Integer = 1

Try
listener = New TcpListener(5000)
listener.Start()


While True
txtOut.Text = "Waiting for connection" & vbCrLf

connection = listener.AcceptSocket()
socketStream = New NetworkStream(connection)
writer = New BinaryWriter(socketStream)
reader = New BinaryReader(socketStream)

txtOut.Text &= "Connection " & counter & " recieved." & vbCrLf

writer.Write("Server>>> Connection Successful")

txtIn.ReadOnly = False
Dim theReply As String = ""

Try
Do
theReply = reader.ReadString()
txtOut.Text &= vbCrLf & theReply
Loop While (theReply <> "Client>>> Terminate" AndAlso connection.Connected)
Catch ex As IOException
MessageBox.Show("Client application closing")
Finally
txtOut.Text &= vbCrLf & "User terminated connection"
txtIn.ReadOnly = True

writer.Close()
reader.Close()
socketStream.Close()
connection.Close()

counter += 1
End Try
End While
Catch ex As IOException
MessageBox.Show("Server application closing")
End Try
End Sub

Adrian De Battista

-- modified at 18:26 Tuesday 21st February, 2006
QuestionCreateObject("WindowsInstaller.Installer") Error Pin
Sysdoc262821-Feb-06 12:18
Sysdoc262821-Feb-06 12:18 
Questioncreating multiple dataset based on query Pin
uglyeyes21-Feb-06 12:00
uglyeyes21-Feb-06 12:00 
AnswerRe: creating multiple dataset based on query Pin
ne0h21-Feb-06 21:16
ne0h21-Feb-06 21:16 
QuestionVlookup function like excel Pin
Sergi2521-Feb-06 11:41
Sergi2521-Feb-06 11:41 
AnswerRe: Vlookup function like excel Pin
Ray Cassick21-Feb-06 11:48
Ray Cassick21-Feb-06 11:48 
QuestionInheritence, disallow ShowDialog() Pin
K. Shaffer21-Feb-06 8:59
K. Shaffer21-Feb-06 8:59 
AnswerRe: Inheritence, disallow ShowDialog() Pin
K. Shaffer21-Feb-06 9:09
K. Shaffer21-Feb-06 9:09 
QuestionVS 2003 to VS 2005 Crystal Reports Hell problems Pin
nordico2521-Feb-06 7:41
nordico2521-Feb-06 7:41 
QuestionCrystal reports via VB.Net Pin
directred21-Feb-06 7:29
directred21-Feb-06 7:29 
QuestionSending HTML emails with MAPI (VB6) Pin
ThePmanLives21-Feb-06 5:47
ThePmanLives21-Feb-06 5:47 
Questionsearching through a site Pin
teuneboon21-Feb-06 4:38
teuneboon21-Feb-06 4:38 
AnswerRe: searching through a site Pin
Divya Rathi22-Feb-06 3:55
Divya Rathi22-Feb-06 3:55 
QuestionUsing a digital camera in my VB project Pin
marclenoir200521-Feb-06 4:16
marclenoir200521-Feb-06 4:16 
QuestionIs there a way to do a spell check on a text box Pin
New_Coder21-Feb-06 3:59
New_Coder21-Feb-06 3:59 
AnswerRe: Is there a way to do a spell check on a text box Pin
uglyeyes21-Feb-06 12:05
uglyeyes21-Feb-06 12:05 
GeneralRe: Is there a way to do a spell check on a text box Pin
New_Coder21-Feb-06 12:12
New_Coder21-Feb-06 12:12 
Questionhow can we use ms agent control in a vb windows application? Pin
kamalika_kk21-Feb-06 3:54
kamalika_kk21-Feb-06 3:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.