From: zzz on 4 Feb 2010 12:04 Hello, Ive created a serial port instance on a module. In the same module I have the sub data_received. Now I'd like to update a control in a form, how can I do it? Thanks in advance
From: Armin Zingler on 4 Feb 2010 19:36 zzz schrieb: > Hello, > Ive created a serial port instance on a module. In the same module I have > the sub data_received. > > Now I'd like to update a control in a form, how can I do it? > Thanks in advance Why don't you declare the serialport variable in the Form? If you want to keep it in the module, you can declare the variable public (or as a public readonly property) and handle the object's event in the Form. -- Armin
From: zzz on 5 Feb 2010 04:33 "Armin Zingler" <az.nospam(a)freenet.de> ha scritto nel messaggio news:%23Z78otfpKHA.4648(a)TK2MSFTNGP06.phx.gbl... > > Why don't you declare the serialport variable in the Form? > If you want to keep it in the module, you can declare the > variable public (or as a public readonly property) and handle > the object's event in the Form. I'd like to have the seialport declared in a module. I've this code: Module1 Public my_object As Object Public WithEvents MySerialPort3 As New MySerialPort Private Sub MySerialPort3_dato_ricevuto(ByVal tipo_scatenante As MySerialPort.tipo_dato) Handles MySerialPort3.dato_ricevuto Select Case tipo_scatenante Case MySerialPort.tipo_dato.versione Case MySerialPort.tipo_dato.dati Select Case (MySerialPort3.data_received.data) Case PEDALE_ON is_pedale_premuto = True Case PEDALE_OFF is_pedale_premuto = False Case Asc("-"), Asc("+") esegui.VarPower(Chr(MySerialPort3.data_received.data)) '<--esegui is a form but it seems that a new instance is created.....In the main form i call it using esegui.showdialog End Select End Select End Sub End module ---------------------------------------------------------- I've also tried to add this code in the main form my_object = esegui' <- I store the information in this global variable declared in the module my_object.ShowDialog() In the module i have replaced esegui.VarPower(Chr(MySerialPort3.data_received.data)) with my_object.VarPower(Chr(MySerialPort3.data_received.data)) ----------------------------------------------------------
From: zzz on 5 Feb 2010 05:04 "DickGrier" <dick_grierNOSPAM(a)msn.com> ha scritto nel messaggio news:%23lL11FfpKHA.3792(a)TK2MSFTNGP06.phx.gbl... > You need to use Control.BeginInvoke or .Invoke to update the UI via a > Delegate. You can download the VB2005 Terminal example from my website, > which illustrates this. > With serial port on form, I have no problem. I use Invoke and delegate.....but using it on module I get issues... Thanks . PS: instead of using invok and delegate, could I access to a class if it is shared?
From: Armin Zingler on 5 Feb 2010 06:26 zzz schrieb: > > "Armin Zingler" <az.nospam(a)freenet.de> ha scritto nel messaggio > news:%23Z78otfpKHA.4648(a)TK2MSFTNGP06.phx.gbl... >> > >> Why don't you declare the serialport variable in the Form? >> If you want to keep it in the module, you can declare the >> variable public (or as a public readonly property) and handle >> the object's event in the Form. > > I'd like to have the seialport declared in a module. > I've this code: > > [Code] I've read the code, but what I meant was handling the event in the Form. In the Form class, just add the eventhandler: addhandler Module1.MySerialPort3.dato_ricevuto, addressof OnDataReceived '... sub OnDataReceived(ByVal tipo_scatenante As MySerialPort.tipo_dato) '... end sub -- Armin
|
Pages: 1 Prev: OpenProcess Help Next: VS2005 - Interacting with external website items via WebBrowser Control |