Click here to Skip to main content
15,911,646 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionFind the difference between two excel sheets using vbscript Pin
Bedke8-Nov-09 16:26
Bedke8-Nov-09 16:26 
QuestionQuestion about threads Pin
crashcup8-Nov-09 12:43
crashcup8-Nov-09 12:43 
AnswerRe: Question about threads Pin
Luc Pattyn8-Nov-09 13:25
sitebuilderLuc Pattyn8-Nov-09 13:25 
GeneralMessage Closed Pin
8-Nov-09 14:27
crashcup8-Nov-09 14:27 
GeneralRe: Question about threads Pin
Luc Pattyn8-Nov-09 15:06
sitebuilderLuc Pattyn8-Nov-09 15:06 
GeneralRe: Question about threads Pin
crashcup8-Nov-09 15:11
crashcup8-Nov-09 15:11 
GeneralRe: Question about threads Pin
Luc Pattyn8-Nov-09 15:13
sitebuilderLuc Pattyn8-Nov-09 15:13 
GeneralRe: Question about threads [modified] Pin
crashcup8-Nov-09 16:10
crashcup8-Nov-09 16:10 
Hmm still no confusion here.
As you can see below the Sub Read() is indeed started by a thread.
And the Read Sub is started from whthin itself.
The program works fine.
And there are Subs as I have 3, 'connect', 'send', and 'read'.
My vocabulary is correct.
These are also considered methods I suppose. But VB calls them Subs or Functions.
Sub procedures are methods which do not return a value.
Function is a method which returns a value.
---------------------------------------------------------------

Public Sub connect(ByVal IP, ByVal Port)
Try
'ccSocket.Connect("127.0.0.1", 2000)
ccSocket.Connect(IP, Port)

Catch ex As Exception

End Try
myThread = New Thread(AddressOf read)
myThread.Start()
End Sub



Public Sub send(ByRef q)
'Dim outStream As Byte() = System.Text.Encoding.ASCII.GetBytes("connect")
'serverStream.Write(outStream, 0, outStream.Length)
'serverStream.Flush()

'Dim serverStream As NetworkStream

Try
serverStream = ccSocket.GetStream()

Dim sendBytes As [Byte]()
sendBytes = Encoding.ASCII.GetBytes(q)
serverStream.Write(sendBytes, 0, sendBytes.Length)
Catch
End Try

End Sub




Public Sub read()
'myThread = New Thread(AddressOf read)
'myThread.Start()

' Read the NetworkStream into a byte buffer.
Dim bytes(ccSocket.ReceiveBufferSize) As Byte

Try
Dim serverStream As NetworkStream
serverStream = ccSocket.GetStream()

serverStream.Read(bytes, 0, CInt(ccSocket.ReceiveBufferSize))

' Output the data received from the host to the console.
Dim returndata As String = Encoding.ASCII.GetString(bytes)
''Console.WriteLine(("Host returned: " + returndata))
DataIn = returndata
Catch ex As Exception

End Try


Try
If Asc(DataIn) = 0 Then
myThread.Abort()
DataIn = "Connection Closed"
End If

Catch ex As Exception
Exit Sub

End Try

Try
myThread = New Thread(AddressOf read)
myThread.Start()
Catch ex As Exception

End Try

End Sub

modified on Monday, November 9, 2009 5:53 AM

GeneralRe: Question about threads Pin
Steven J Jowett9-Nov-09 9:38
Steven J Jowett9-Nov-09 9:38 
GeneralRe: Question about threads Pin
Luc Pattyn9-Nov-09 9:54
sitebuilderLuc Pattyn9-Nov-09 9:54 
AnswerRe: Question about threads Pin
Dave Kreskowiak8-Nov-09 13:25
mveDave Kreskowiak8-Nov-09 13:25 
GeneralRe: Question about threads Pin
crashcup8-Nov-09 14:18
crashcup8-Nov-09 14:18 
GeneralRe: Question about threads Pin
Dave Kreskowiak8-Nov-09 14:50
mveDave Kreskowiak8-Nov-09 14:50 
GeneralRe: Question about threads Pin
crashcup8-Nov-09 15:09
crashcup8-Nov-09 15:09 
GeneralRe: Question about threads Pin
Dave Kreskowiak9-Nov-09 2:10
mveDave Kreskowiak9-Nov-09 2:10 
QuestionSorting an Array ASCENDING ORDER Pin
PAguilar098-Nov-09 9:31
PAguilar098-Nov-09 9:31 
AnswerRe: Sorting an Array ASCENDING ORDER Pin
Luc Pattyn8-Nov-09 9:40
sitebuilderLuc Pattyn8-Nov-09 9:40 
AnswerRe: Sorting an Array ASCENDING ORDER Pin
Luc Pattyn8-Nov-09 10:06
sitebuilderLuc Pattyn8-Nov-09 10:06 
GeneralRe: Sorting an Array ASCENDING ORDER Pin
PAguilar098-Nov-09 14:53
PAguilar098-Nov-09 14:53 
GeneralRe: Sorting an Array ASCENDING ORDER Pin
Luc Pattyn8-Nov-09 15:12
sitebuilderLuc Pattyn8-Nov-09 15:12 
GeneralRe: Sorting an Array ASCENDING ORDER Pin
PAguilar099-Nov-09 3:15
PAguilar099-Nov-09 3:15 
QuestionHow to add all the items of treeview within the combobox? Pin
Milad.Biroonvand8-Nov-09 1:21
Milad.Biroonvand8-Nov-09 1:21 
AnswerRe: How to add all the items of treeview within the combobox? Pin
Milad.Biroonvand8-Nov-09 2:31
Milad.Biroonvand8-Nov-09 2:31 
GeneralRe: How to add all the items of treeview within the combobox? Pin
Steven J Jowett8-Nov-09 5:40
Steven J Jowett8-Nov-09 5:40 
QuestionHow to get a movie resolution (film file) Pin
Milad.Biroonvand7-Nov-09 21:03
Milad.Biroonvand7-Nov-09 21:03 

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.