0% found this document useful (0 votes)
3 views3 pages

Excel

hgfhyj
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Excel

hgfhyj
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

using System;

using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using Excel = [Link];

namespace WindowsFormsApplication5
{
public partial class lis : Form
{
[Link] xlexcel;
[Link] xlWorkBook;
[Link] xlWorkSheet;
object misValue = [Link];
public lis()
{
InitializeComponent();
}

int z;
string bacadata;

private void button1_Click(object sender, EventArgs e)


{
try
{
if (z == 0)
{
if ([Link] != "")
{
s_port1.PortName = [Link];
//s_port1.BaudRate =
Convert.ToInt32([Link]);
s_port1.Open();
s_port1.NewLine = "\r\n";
z = z + 1;
[Link] = s_port1.PortName +
"Terhubung";
//[Link] = "Baud Rate adalah " +
[Link];
xlexcel = new [Link]();

[Link] = true;

// Open a File
xlWorkBook = [Link]("D:\\[Link]",
0, true, 5, "", "", true,
[Link], "\t",
false, false, 0, true, 1, 0);

xlWorkSheet =
([Link])[Link].get_Item(1);
[Link][1, 1] = "Suhu";
[Link][1, 2] = "Kelembaban";
[Link][1, 3] = "Tekanan Udara";
[Link][1, 4] = "UV";
}
else
[Link]("Anda Belum Terhubung Kemana - Mana");
}
else
{
[Link]("Anda Sudah Terhubung");
}
}
catch (UnauthorizedAccessException)
{
[Link]("Port Sudah Terpakai");
}
}

private void Form1_Load(object sender, EventArgs e)


{
String[] portList = [Link]();
foreach (String portName in portList)
[Link](portName);
//[Link](s_port1.BaudRate);
[Link] = false;
}

private void button2_Click(object sender, EventArgs e)


{
try
{
s_port1.Close();
[Link]("Anda Sudah Terputus");
[Link] = "";
}
catch (UnauthorizedAccessException)
{
[Link]("Anda Belum Terhubung Kemana - Mana");
}
}

private void s_port1_DataReceived(object sender,


SerialDataReceivedEventArgs e)
{
Tampilkan(s_port1.ReadLine());
}
private delegate void TampilkanDelegate(object item);
private void Tampilkan(object item)
{
if (InvokeRequired)
[Link](new TampilkanDelegate(Tampilkan), item);
else
[Link](item);
bacadata = [Link](item);
string[] kata = [Link](',');
[Link] = kata[1];
[Link] = kata[2];
tek_udara.Text = kata[3];
[Link] = kata[4];
}

private void baca_Click(object sender, EventArgs e)


{
if (s_port1.IsOpen == true)
{
[Link] = true;
}
else
{
[Link]("Anda Belum Terhubung Kemana - Mana");
}
}

private void clear_Click(object sender, EventArgs e)


{
[Link]();
[Link] = "";
[Link] = "";
tek_udara.Text = "";
[Link] = "";
}

private void timer1_Tick_1(object sender, EventArgs e)


{
if (z == 1)
{
s_port1.WriteLine("AA");
int _lastRow = [Link]["A" +
[Link]].End[[Link]].Row + 1;

[Link][_lastRow, 1] = [Link];
[Link][_lastRow, 2] = [Link];
[Link][_lastRow, 3] = tek_udara.Text;
[Link][_lastRow, 4] = [Link];
}
else
{
[Link]("Anda Belum Terhubung Kemana - Mana");
}
}
}
}

You might also like