Hello, I ‘m a beginner and have a project that I’m using to turn lights on and off.
I need to use separate forms for display on remote monitors. My problem is each form needs the same serial port open to work and the port won’t open unless it’s closed in the previous form. Using a module works for opening and closing the port, but only for one round. If I try to revisit a form I already accessed it doesn’t work.
Thanks for any suggestions.
I call up one of these subs at the beginning of each form
Module port1
Public SerialPort1 AsControl
Public Sub sp1(byval SerialPort1)
If Form2.SerialPort1.IsOpen = TrueThen Form1.SerialPort1.Close()
If Form3.SerialPort1.IsOpen = TrueThen Form3.SerialPort1.Close()
Form1.SerialPort1.Open()
end sub
Public Sub sp2(byval SerialPort1)
If Form1.SerialPort1.IsOpen = TrueThen Form1.SerialPort1.Close()
If Form3.SerialPort1.IsOpen = TrueThen Form3.SerialPort1.Close()
Form2.SerialPort1.Open()
EndSub
Public Sub sp3(byval SerialPort1)
If Form1.SerialPort1.IsOpen = TrueThen Form1.SerialPort1.Close()
If Form2.SerialPort1.IsOpen = TrueThen Form3.SerialPort1.Close()
Form2.SerialPort1.Open()
EndSub
end Module
I need to use separate forms for display on remote monitors. My problem is each form needs the same serial port open to work and the port won’t open unless it’s closed in the previous form. Using a module works for opening and closing the port, but only for one round. If I try to revisit a form I already accessed it doesn’t work.
Thanks for any suggestions.
I call up one of these subs at the beginning of each form
Module port1
Public SerialPort1 AsControl
Public Sub sp1(byval SerialPort1)
If Form2.SerialPort1.IsOpen = TrueThen Form1.SerialPort1.Close()
If Form3.SerialPort1.IsOpen = TrueThen Form3.SerialPort1.Close()
Form1.SerialPort1.Open()
end sub
Public Sub sp2(byval SerialPort1)
If Form1.SerialPort1.IsOpen = TrueThen Form1.SerialPort1.Close()
If Form3.SerialPort1.IsOpen = TrueThen Form3.SerialPort1.Close()
Form2.SerialPort1.Open()
EndSub
Public Sub sp3(byval SerialPort1)
If Form1.SerialPort1.IsOpen = TrueThen Form1.SerialPort1.Close()
If Form2.SerialPort1.IsOpen = TrueThen Form3.SerialPort1.Close()
Form2.SerialPort1.Open()
EndSub
end Module
Last edited: