Jump to content
Xtreme .Net Talk

Showing some text received from a COM port into a textbox, in VB.NET


Recommended Posts

Posted

Hi,

 

This is a little about my last post, but i'll ask for help in other terms.

Basically, i've a Terminal that reads the COM port and i'm using VS2005 Team System Beta2 an VB.NET, i'm making all ok about the settings of the serial port and so on but i cannot show the received text into a textbox.

Problem:Cross-Thread.... can not access to the textbox because in a diferent thread...

How can i solve this and show the received text without any problem, i thought o could solve this using the delegates but i was unable to do that ( that was the objective of my last thread ) any help?

 

I saw an example but in C#, that invokes the method AppendText() of the textbox and it was ok but i couldn't solve this in VB.NET.

 

Thanks,

 

Best Regards,

 

Teixeira

Posted

You may want to look at this example. http://zone13.net/zone13/default.asp?PageAction=TECHTALK&TechID=539. It uses a class to pass a variable to a thread. You could change the integer value to a 'ByRef' of your textbox like this.

 

'pseudocode
'FORM
Dim MyClass as New ExampleClass(MyTextBox)


'CLASS
'Init
Public TextBox1 as TextBox
Sub New(ByRef tb as TextBox)
   TextBox1 = tb
End Sub

'Use
Sub ThreadProcessLoop()
  do forever
       TextBox1.Text &= MyValueMadeInThisThread
  loop
End SUb

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...