Serial Port Added In One Form Not Accessible From Another Class?
Apr 19, 2011
I added a serial port com1 to my vb.net form. I created a new class and wrote a method to open the com1 and created its object in the main form and called the method and its opening.THen i created another class wrote a method to write data to the com and same way created an object and called it but i am getting the error as port is closed. What am i doing wrong.
View 1 Replies
ADVERTISEMENT
Jul 25, 2011
I have a Windows form.in windows form have a combo box that give me a list of available port serial with it code (Dim ports As String() =SerialPort.GetPortNames())for example( Com1,Com8,Com15,...).but I want to give me fullname of serial port in device manager for example in dvice manager is these (Comunication Port(COM1) - Printer Port(LPT1) And USB Serial Port(COM8)).how to Get it?
View 2 Replies
Apr 24, 2010
I'm learning the serial port programming. So, I study the code samples from MSDN - VB101SamplesBCL2 http:[url].....While ran the solution of "UsingTheSerialPort", It shows error: It highlights one sentence textBox2.Text = SerialPort1.ReadLine() -- Line 40 ,and says :
"InvalidOperationException was unhandled - Cross-thread operation not valid: Control 'textBox2' accessed from a thread other than the thread it was created on."
View 1 Replies
Feb 15, 2011
I have a problem with read() method of serial port class, when I build my program my application doesn't respond or blocked!!
My code was something like this:
dim bRxdata(6) as Byte
...
serialport1.read(bRxdta, 0, 6)
I use vb 2008 xpress, win7 x86.
View 4 Replies
Aug 10, 2010
I am looking for a serial port component for .NET that overcomes the issues with the built-in Serial Port component related to sudden unplugging of USB-to-RS232 adapters, and suspension of the computer while the port is open. (Untrappable errors occurring after the the device is unplugged or the computer comes back after being suspended.)I have been using Richard Grier's solution, but I still have problems when resuming from suspend.Is there a 3rd party component that you would recommend? I have tried several, and each have their shortcomings. Ideally I'd like a drop-in replacement for the standard serial port, but I'll take whatever I can get.
Edit: It turns out that upgrading to .NET 4 and using the serial class works fine on XP, but does not work on Windows 7.
View 2 Replies
Aug 16, 2011
i am a absolute beginner and i want to use vb to receive data from micro controller through serial port using rs232 standards, i found this code to receive the data serially, can any one tell me where should i paste this code, so that the data received will be displayed in message box.Private Sub DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) HandlesSerialPort1.DataReceived
[Code]...
View 9 Replies
Oct 26, 2011
The link below has code to connect to a modem thru the serial port but it is for an earlier version of VB. when I convert the code, it does not fully convert and has 4 errors that prevent building the project. can someone tell me what needs to be changed or added?
[URL]
Note: the error: not CLS-Compliant
View 8 Replies
Feb 18, 2010
Hi
I've got a pretty general question about the best practice in passing an object reference to a Form in VB.NET. My form is a dialog and I've created an overload ShowDialog method, where I pass an Object into it ByRef.
The trouble is, I want to be able to refer to that Object throughout my dialog Class and not just in the ShowDialog method. For instance, some of my Events for controls on the form, need to reference that object.
I know I could create a local Private variable in the Class and assign it to the passed value, and then use that value. However I'm thinking this isn't very efficient because it would (I believe) create a new copy of the Object (which is a complex, large class in itself).
View 8 Replies
Jul 8, 2008
I have a programme that accepts data from a serial port. If I close the port and then the form no problem. However if I try to close the form with out closing the port it appears to hang. I have tried closing the port in the forms close event but this did not solve the problem.The data recieved event is as below and UseData is the private sub which actually handles the data. Usedata contains the code line Dim InputText As String = SerialPort1.ReadLine
Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Me.Invoke(New myDelegate(AddressOf UseData), New Object() {})
End SubI am aware that this event runs on another thread and I have seen but cannot now find information about closing multiple active threads.or do I have to "uninvoke" the delegate
View 1 Replies
Feb 13, 2009
first post here at the forums. I am a complete noob when it comes to VB .Net, but I have done a lot of VBA programming and some VB6 back in the day. I have posted this question on two other forums (including the MSDN forums) and no one has responded so please let me know if I need to clarify the question.
I am (trying) to write my first .net app which reads/writes data to a device connected over the serial port. I have manged to get it to work to send commands to the device and receive the reply back, mainly using the info from this article: Beth Massi - Sharing the goodness that is VB : Reading from a Serial Port and Saving to a Database
However, I am having problems with updating the controls on the main form based on the received data from the serial port. Basically I want the user to click a button (one of six on the form) which will send data to the device, then based on the response from the device, the BackColor of that particular button, will be changed accordingly. I just am missing something b/c the button click is a different sub than the sub that handles the form controls update and I can't get the two to talk
[Code]...
View 5 Replies
Mar 28, 2006
I have a stand alone VB.Net 2005 application that uses a serial port that generally stays open while the application runs on a Windows XP system. In trying to bullet-proof the UI, I ran into a problem when the USB to Serial Converter normally used to provide the serial port is disconnected while the serial port is open. In trying to handle the resulting error when accessing the port, I find I cannot close the port.
When trying to do so, the error message says something like "unable to close the port. You may not have sufficient permissions." Reconnecting the USB/Serial Converter does not reactivate the port.
[Code]...
View 8 Replies
Nov 27, 2010
I'm mohammed from Oman ,I'm visual studio.net programmer How I can Read the Data From Barcode Weight scales By Serial port and TcpIp port
View 7 Replies
Aug 2, 2011
If I uninstall the COM1 and reboot, it works. If I shut down (power off) and restart, I get the message below. If I uninstall then click on Scan for Hardware Changes,The given port name does not start with COM/com or does not resolve to a valid serial port. Parameter name:portName
View 8 Replies
Oct 15, 2008
Im having problem with the Serial Port. When i run my program, "Access to the port 'COM1' is denied". What does that mean? Im not sure whats happening because theres no error in my code. Someone suggest me to use 'COM2'. Which is also the same result. I have a microcontroller, programmed and run it. And i need to capture the data onto my vb, which is on a multiline textbox. How to i do that?Just to double check my code?
[code]...
View 1 Replies
Feb 28, 2010
I can't understand it..let me show you what i have first :
CODE:
and
CODE:
in ReportsOfficesEntities.vb:
CODE:
in BaseController.vb:
CODE:
And of course i added the references for both projects...
the error in BaseController.vb:
CODE:
I checked the whole code ..wondering if i am missing something ... nothing!
searched -->
1: maybe it is different a littel... i don't know
2:i am not sure if it is the same issue .. and it looks complicated to me..
note: i copy (Convert) that from C#.net project and it is working just fine in (C#.net)....!
View 1 Replies
Sep 12, 2009
I am trying to create a Class that is COM accessible.The problem I am having is that I cannot have any arguments in the class constructor Sub New.If I do than I get the error:"MSB3214 does not contain any types that can be registered for COM Interop"I can however afterwards use regasm ComDotNet.dll /tlb to create the tlb file.
However when I try to use the class in VB (after adding the reference) withDim test As ComDotNet.HelloDotNetSet test = New ComDotNet.HelloDotNet("Hello")I get an error.
If I remove the argument from Sub New() everything works fine.
Here is the code:
Code:Imports SystemImports System.Runtime.InteropServices
Public Interface IHelloDotNet Function GetAge() As Integer Sub SayHello()End Interface
[Code].......
View 2 Replies
Jul 7, 2011
I'll try to explain this the simplest way I can, and I'll be happy to provide more elaboration as needed.
I've created a class, class playership, as part of a little strategy game for my own practice.
I've created the instance of a playership object in my main form using the following [code]...
I'm a little confused about this because I thought a public object or variable could be accessed from anywhere within a project.
View 4 Replies
Nov 26, 2010
I have an issue with FxCop and the warning: Abstract types should not have constructors.This is being displayed for a number of abstract classes (possibly all, I haven't checked). When I look most of them have no new method so I assume it's the complier adding a default one. So to remove it I add a private default constuctor (Private Sub New()), this then means all the inherting classes fail to build with the error: Class 'InheritingClass' has no accessible 'Sub New' and cannot be inherited.This seems odd as FxCop requests no public constructor, but when I remove it the build fails.
View 1 Replies
Jun 24, 2009
In general, according to the OOP paradigm, my understanding of encapsulation basically says:
-If a member is private, it can only be accessed by the class.
-If a member is protected, it can only be accessed by the base class and any derived classes.
-If a member is public, it can be accessed by anyone.
If I have a nested class, can I declare a property to be accessible only to that class and the parent class it's nested within? For example:[code]In the example, I cannot directly access myNestedObject.myInt or myNestedObject.myDbl from an instance of ContainerClass if those members are Private or Protected. But suppose I don't want to make them Public,because then they are TOO exposed: they can be altered from anywhere, not just within a Container Class object. Declaring them Friend would still be too weak as that would allow them to be altered from anywhere within the application.
View 2 Replies
Jun 3, 2012
I am trying to buld a DLL in VB.NET 2010 that will be use to control a vending machine.Whin a call into the DLL to a function to open and setup the comport the first time its opens it just fine, but if a call into the DLL again it does not know that the port is open even if it is still open. I can check with another program and is shows the port is open and if I try to call into the DLL again to open the port I get an error that the port is already open. Any idea how to set this up so it will work
View 7 Replies
Dec 30, 2009
i'm creating a windows form to send/receive data to/from serial port.At first : i send the data as string to the serial port .Second: i tried to read the string again for test the successfull transmission , but i recieved empty string
[Code]...
View 4 Replies
Oct 21, 2011
I can find documentation (preferably with code samples) that will guide me through all the steps to activate and read from a serial port?
View 6 Replies
Oct 31, 2010
For my application a need to set a breakstate on/off of 25ms.In Xp this runs fine when I set breakstate=true and wait for 25ms and then breakstate= false and wait 25ms.In CE6.0 when I set breakstate = true, it only throws a puls.It is even not possible to keep breakstate on.
how to solve this or is there an alternative to simulate a breakstate?
View 3 Replies
Jan 15, 2011
can we communicate to Serial port COM1 through Microsoft Robotic Studio?We are developing wireless robot which will take data from serial por
View 14 Replies
Mar 8, 2010
For many years, I have sent data between 2 computers using serial ports."Here is the data", "Thank you for that data!" type stuff.Where do I get more information for doing the same thing with 2 computers that are networked together? Assume a local ethernet connection.I have experimented with serial-ethernet modems and that works well but I don't want any more hardware.Is there a good thread here I should read?I want 2 VB programs running and I want to exchange data periodically.
View 2 Replies
Apr 23, 2006
I know things have changed in VB2005.net and i have Express and i want to controll the serial port. I have a program from VB6 that i understand and i tried to convert it but i get alot of errors and i have know idead what they mean. As you can tell i haven't been programming very long.
If someone can point me in the right direction for programming the serial port in VB2005 .net i would appreciate it or tell me what differences there may be.
View 12 Replies
Nov 9, 2009
I am developing a UI for an embedded device that I have designed and built. The device uses an FT232 chip which, when connected via USB is automatically assigned one of the COM ports. I was wondering if there is a way to set up a loop which would automatically detect which COM port the device has been assigned. I could then add some handshaking to verify that the port is correct.
View 4 Replies
Feb 16, 2009
I have a little code for get the serial port available in the system.
For Each pn As String In IO.Ports.SerialPort.GetPortNames
Debug.WriteLine("NAME : " + pn.ToString)
Next
[Code]....
So, The PORT1 and PORT5 its ok (because this are real serial port, with a real RS232 interface), but PORT4, I don't know.
How I can do for get only true serial ports ?
View 3 Replies
Jan 30, 2011
I am facing problem reading data from Serial port. Actually I am connecting with the hardware device called Crimp Force Analyzer. It gives the data on hyperterminal and I have to read that data from my <acronym title="Visual Basic">vb</acronym>.net program. The data is somewhat like this:
[Code]....
View 8 Replies
Oct 29, 2009
I'm looking for a program that would read and import data from my serial port and then graph it. I don't mind buying it if it's not a free program.
View 6 Replies