\r\n\r\n
Visual Basic .NET Do NOT post questions here simply because you're using Visual Basic .NET. This forum is for syntax related questions only!

Go Back  Xtreme .NET Talk > .NET > Syntax Specific > Visual Basic .NET > VB6 and VB.NET Serial (COM1) data error


\r\n \r\n
 
 
Thread Tools Display Modes


\r\n\r\n\r\n
Hello,
\r\nI\'m new to .NET. I have an application that is running in VB6. It sends text through COM1 port to another device.
\r\n
\r\nWhen I converted the VB6 code to .NET the string it sends out is different! I have tried so many things and don\'t know what to do. I used a serial data analyzer and found the two strings are different even the the source code is the same.
\r\n
\r\nVB6 source code:
\r\n MSComm1.CommPort = 1
\r\n MSComm1.Settings = "9600,O,8,1"
\r\n MSComm1.PortOpen = True
\r\n MSComm1.Output = Chr(&H2B) & _
\r\n Chr(&H4) & _
\r\n Chr(&H3) & _
\r\n Chr(&HE8) & _
\r\n Chr(&H0) & _
\r\n Chr(&H2) & _
\r\n Chr(&HF6) & _
\r\n Chr(&H71)
\r\n MSComm1.PortOpen = False
\r\n
\r\nThe analyzer gets the following string in hex: 2B 04 03 E8 00 02 F6 71

\r\n
\r\nVB.NET source code:

\r\n Dim Port As SerialPort = New SerialPort("COM1", 9600, Parity.Odd, 8, StopBits.One)
\r\n Port.Open()
\r\n Port.Write(System.Convert.ToChar(&H2B) & _
\r\n System.Convert.ToChar(&H4) & _
\r\n System.Convert.ToChar(&H3) & _
\r\n System.Convert.ToChar(&HE8) & _
\r\n System.Convert.ToChar(&H0) & _
\r\n System.Convert.ToChar(&H2) & _
\r\n System.Convert.ToChar(&HF6) & _
\r\n System.Convert.ToChar(&H71))
\r\n Port.Close()
\r\n
\r\nThe analyzer gets the following string in hex: 2B 04 03 0F 00 02 3F 71
\r\n
\r\nWhy is there a difference in the string?
\r\nPlease help me correct it...
\r\nThanks
\r\n \r\n
\r\n \r\n\r\n \r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n \r\n\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n'; pd[472399] = '\r\n\r\n \r\n\r\n
\r\n
\r\n
\r\n\r\n
\r\n \r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n \r\n
\r\n
\r\n  \r\n #2  \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n
\r\n \r\n Old\r\n \r\n 02-03-2011, 03:37 AM\r\n \r\n \r\n \r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n
\r\n \r\n aattanayake\r\n aattanayake is offline\r\n\r\n\r\n
Prev Previous Post   Next Post Next
  #1  
Old 02-02-2011, 09:49 PM
aattanayake aattanayake is offline
Newcomer
 
Join Date: Feb 2011
Posts: 3
aattanayake is on a distinguished road
Unhappy VB6 and VB.NET Serial (COM1) data error



Hello,
I'm new to .NET. I have an application that is running in VB6. It sends text through COM1 port to another device.

When I converted the VB6 code to .NET the string it sends out is different! I have tried so many things and don't know what to do. I used a serial data analyzer and found the two strings are different even the the source code is the same.

VB6 source code:
MSComm1.CommPort = 1
MSComm1.Settings = "9600,O,8,1"
MSComm1.PortOpen = True
MSComm1.Output = Chr(&H2B) & _
Chr(&H4) & _
Chr(&H3) & _
Chr(&HE8) & _
Chr(&H0) & _
Chr(&H2) & _
Chr(&HF6) & _
Chr(&H71)
MSComm1.PortOpen = False

The analyzer gets the following string in hex: 2B 04 03 E8 00 02 F6 71


VB.NET source code:

Dim Port As SerialPort = New SerialPort("COM1", 9600, Parity.Odd, 8, StopBits.One)
Port.Open()
Port.Write(System.Convert.ToChar(&H2B) & _
System.Convert.ToChar(&H4) & _
System.Convert.ToChar(&H3) & _
System.Convert.ToChar(&HE8) & _
System.Convert.ToChar(&H0) & _
System.Convert.ToChar(&H2) & _
System.Convert.ToChar(&HF6) & _
System.Convert.ToChar(&H71))
Port.Close()

The analyzer gets the following string in hex: 2B 04 03 0F 00 02 3F 71

Why is there a difference in the string?
Please help me correct it...
Thanks
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Serial Data kenbo General 1 06-25-2009 01:37 PM
Error When Trying to Use .NET DLL in VB6 DVader Interoperation / Office Integration 3 08-21-2006 04:09 PM
Optimizing Serial Data Acquisition beyerch General 4 09-29-2005 01:48 PM
geting data in through the serial port fguihen General 3 05-14-2004 03:22 AM
using win32 with c# for serial data transferr fguihen Interoperation / Office Integration 1 01-14-2004 12:33 PM

Advertisement:







Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe