Click here to Skip to main content
16,020,315 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: text box,vb.net Pin
TnTinMn1-Nov-13 17:33
TnTinMn1-Nov-13 17:33 
GeneralRe: text box,vb.net Pin
srinivasankrishnaa2-Nov-13 18:57
srinivasankrishnaa2-Nov-13 18:57 
QuestionReplacing one character instead of other,vb.net Pin
srinivasankrishnaa31-Oct-13 4:41
srinivasankrishnaa31-Oct-13 4:41 
AnswerRe: Replacing one character instead of other,vb.net Pin
Eddy Vluggen31-Oct-13 6:02
professionalEddy Vluggen31-Oct-13 6:02 
GeneralRe: Replacing one character instead of other,vb.net Pin
srinivasankrishnaa31-Oct-13 23:59
srinivasankrishnaa31-Oct-13 23:59 
Question[VB.NET 2008] How to write in a textbox from another thread Pin
steve_949661329-Oct-13 5:48
professionalsteve_949661329-Oct-13 5:48 
AnswerRe: [VB.NET 2008] How to write in a textbox from another thread Pin
Eddy Vluggen29-Oct-13 8:35
professionalEddy Vluggen29-Oct-13 8:35 
GeneralRe: [VB.NET 2008] How to write in a textbox from another thread Pin
steve_949661330-Oct-13 3:45
professionalsteve_949661330-Oct-13 3:45 
Thanks Eddy.
I have modified the first function as you suggested to do for the second one:
VB
Public Sub ScriviTesto2(ByVal dato As Byte)
  Dim str As String

  If InvokeRequired Then
    Invoke(New Action(Of Byte)(AddressOf ScriviTesto2), dato)
    'Invoke(New Action(AddressOf ScriviTesto2))
    Return
  End If

  Try
    'str = Hex(byt)
    'dati &= str & " "
    str = Hex(dato)
    dati &= str & " "
    TB1.Text &= Hex(dato) & " "
    'TB1.Text = dati
  Catch ex As Exception
    MessageBox.Show(ex.ToString)
  End Try
End Sub

In the receiver thread I call this function every byte I receive, passing to it the byte just received.
As before the string dati grows byte by byte so I can say that I correctly pass the parameter dato to this function but nothing is written in the text box TB1.
Writing byte by byte in a textbox is not the fastest way but I just wanted to see if passing data as parameter to the function could be the solution.
Perhaps the text box is not the right objet to use or, more likely, I'm missing something important.

I did another try: as you suggested I created a byte array in the receiver thread, I fill it with the bytes received and at the end of data reception I call another function in form1 passing to it the byte array:
VB
Public Sub ScriviTesto4(ByVal datiIn As Byte())
  Dim i As Int32

  If InvokeRequired Then
    Invoke(New Action(Of Byte())(AddressOf ScriviTesto4))
    Return
  End If

  For i = 0 To (datiIn.Count - 1)
    TB1.Text &= Hex(datiIn(i)) & " "
  Next
  TB1.Text &= vbCrLf

End Sub

Running step by step in debug I see that the array datiIn contains the right bytes and also the TB1.Text contains the right values but I see nothing in the text box in the form!

What I'm doing wrong?
QuestionRe: [VB.NET 2008] How to write in a textbox from another thread Pin
Eddy Vluggen30-Oct-13 11:06
professionalEddy Vluggen30-Oct-13 11:06 
AnswerRe: [VB.NET 2008] How to write in a textbox from another thread Pin
steve_949661330-Oct-13 22:13
professionalsteve_949661330-Oct-13 22:13 
GeneralRe: [VB.NET 2008] How to write in a textbox from another thread Pin
Eddy Vluggen31-Oct-13 9:11
professionalEddy Vluggen31-Oct-13 9:11 
GeneralRe: [VB.NET 2008] How to write in a textbox from another thread Pin
steve_94966133-Nov-13 21:19
professionalsteve_94966133-Nov-13 21:19 
QuestionHow to read a text file containing Arabic chars in VB.Net 2005? Pin
dgthecodeproject29-Oct-13 1:51
dgthecodeproject29-Oct-13 1:51 
AnswerRe: How to read a text file containing Arabic chars in VB.Net 2005? Pin
Eddy Vluggen29-Oct-13 8:29
professionalEddy Vluggen29-Oct-13 8:29 
QuestionError with Assembly reference Pin
indian14328-Oct-13 7:43
indian14328-Oct-13 7:43 
AnswerRe: Error with Assembly reference Pin
Eddy Vluggen29-Oct-13 8:23
professionalEddy Vluggen29-Oct-13 8:23 
GeneralRe: Error with Assembly reference Pin
indian14329-Oct-13 13:21
indian14329-Oct-13 13:21 
GeneralRe: Error with Assembly reference Pin
Eddy Vluggen30-Oct-13 11:02
professionalEddy Vluggen30-Oct-13 11:02 
GeneralRe: Error with Assembly reference Pin
indian14331-Oct-13 6:48
indian14331-Oct-13 6:48 
GeneralRe: Error with Assembly reference Pin
Eddy Vluggen31-Oct-13 9:34
professionalEddy Vluggen31-Oct-13 9:34 
Question[VB.NET 2008] How to use DeviceIoControl function? Pin
steve_949661328-Oct-13 3:06
professionalsteve_949661328-Oct-13 3:06 
AnswerRe: [VB.NET 2008] How to use DeviceIoControl function? Pin
David Knechtges28-Oct-13 3:14
David Knechtges28-Oct-13 3:14 
GeneralRe: [VB.NET 2008] How to use DeviceIoControl function? Pin
steve_949661328-Oct-13 3:47
professionalsteve_949661328-Oct-13 3:47 
GeneralRe: [VB.NET 2008] How to use DeviceIoControl function? Pin
David Knechtges29-Oct-13 3:13
David Knechtges29-Oct-13 3:13 
GeneralRe: [VB.NET 2008] How to use DeviceIoControl function? Pin
steve_949661329-Oct-13 4:55
professionalsteve_949661329-Oct-13 4:55 

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.