Add an electronic weigh program

Source: Internet
Author: User

Define a delegate:

Delegate void Electronicscales (string  str); Electronicscales strc;


In the initialization of the electronic weigh:

       #regionElectronic weighing settings Public voidElectronic () {//Initialization Window program accepts electronic scale information            Try{serialport1.portname="COM3"; Switch(Share.getcompanyid ()) { Case 1: Serialport1.baudrate= -;  Break; default: Serialport1.baudrate=2400;  Break; } strc=Newelectronicscales (Updatetextbox); Serialport1.datareceived+=NewSystem.IO.Ports.SerialDataReceivedEventHandler (serialport1_datareceived);                Serialport1.close ();            Serialport1.open (); }            Catch            {            }        }        Private voidUpdatetextbox (stringweight) {Trueweight=int.   Parse (weight); Trueweight interface text Box}Private voidSerialport1_datareceived (Objectsender, System.IO.Ports.SerialDataReceivedEventArgs e) {            Try            {                varStrweight =""; Thread.Sleep ( $); stringcom =serialport1.readexisting (); Char[] ch = com. Substring (COM. IndexOf ("=") +1,6).                ToCharArray ();                Array.reverse (CH); Strweight= Convert.ToInt32 (New string(CH)).                ToString ();  This. Invoke (STRC,New string[] {strweight}); }            Catch            {            }        }        #endregion

COM3 is the port number, you need to set the port number to COM3

Add an electronic weigh program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.