using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace testing2
{
public partial class Form2 : Form
{
Formload callingForm;
public Form2(Formload form)
{
InitializeComponent();
callingForm = form;
}
private void sndbtn_Click(object sender, EventArgs e)
{
if (!callingForm.serialPort1.IsOpen)
callingForm.serialPort1.Open();
float Mx1;
float Mx2;
float Mx3;
float Mx4;
float Cx1;
float Cx2;
float Cx3;
float Cx4;
Mx1 = float.Parse(txtMx1.Text);
Cx1 = float.Parse(txtCx1.Text);
Mx2 = float.Parse(txtMx2.Text);
Cx2 = float.Parse(txtCx2.Text);
Mx3 = float.Parse(txtMx3.Text);
Cx3 = float.Parse(txtCx3.Text);
Mx4 = float.Parse(txtMx4.Text);
Cx4 = float.Parse(txtCx4.Text);
string s = "\x2" + "a" + txtMx1.Text + "b" + txtCx1.Text + "\x3" + "\x2" + "c" + txtMx2.Text + "e" + txtCx2.Text + "\x3"+"\x2" + "w" + txtMx3.Text + "x" + txtCx3.Text + "\x3"+"\x2" + "y" + txtMx4.Text + "z" + txtCx4.Text + "\x3";
char[] cArr = s.ToCharArray();
foreach (char c in cArr)
{
char[] buff = { c };
callingForm.serialPort1.Write(cArr, 0, s.Length);
}
}
}
}
This post has been edited by JackOfAllTrades: 31 August 2012 - 03:27 AM
Reason for edit:: Fixed code tags

New Topic/Question
Reply




MultiQuote




|