想不通很久了,找大虾:
'以下是手动采集的代码
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
flag2 = 1
flag1 = 0
Timer1.Enabled = False
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
MSComm1.Output = Chr(27) + "p"
TextBox1.Text = Chr(27) + "p"
Do
Application.DoEvents() If flag1 = 1 Then GoTo 10
Loop Until MSComm1.InBufferCount >= 13
a = MSComm1.Input
Label1.Text = Mid(a, 1, 9)
Label2.Text = Mid(a, 10, 3)
10: If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
End Sub
'以下是手动采集的代码
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
flag2 = 1
flag1 = 0
Timer1.Enabled = False
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
MSComm1.Output = Chr(27) + "p"
TextBox1.Text = Chr(27) + "p"
Do
Application.DoEvents() If flag1 = 1 Then GoTo 10
Loop Until MSComm1.InBufferCount >= 13
a = MSComm1.Input
Label1.Text = Mid(a, 1, 9)
Label2.Text = Mid(a, 10, 3)
10: If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
End Sub
private void Button6_Click(object sender, System.EventArgs e)
{
flag2 = 1;
flag1 = 0;
Timer1.Enabled = false;
if (MSComm1.PortOpen == false) {
MSComm1.PortOpen = true;
}
MSComm1.Output = Strings.Chr(27) + "p";
TextBox1.Text = Strings.Chr(27) + "p";
do {
Application.DoEvents();
if (flag1 == 1)
goto 10;
}
while (!(MSComm1.InBufferCount >= 13));
a = MSComm1.Input;
Label1.Text = Strings.Mid(a, 1, 9);
Label2.Text = Strings.Mid(a, 10, 3);
10:
if (MSComm1.PortOpen == true)
MSComm1.PortOpen = false;
}
private void Button6_Click(object sender, System.EventArgs e)
{
flag2 = 1;
flag1 = 0;
Timer1.Enabled = false;
if (MSComm1.PortOpen == false) {
MSComm1.PortOpen = true;
}
MSComm1.Output = Strings.Chr(27) + "p";
TextBox1.Text = Strings.Chr(27) + "p";
do {
Application.DoEvents();
if (flag1 == 1)
goto L10;
}
while (!(MSComm1.InBufferCount >= 13));
a = MSComm1.Input;
Label1.Text = Strings.Mid(a, 1, 9);
Label2.Text = Strings.Mid(a, 10, 3);
L10:
if (MSComm1.PortOpen == true)
MSComm1.PortOpen = false;
}
private void Button6_Click(object sender, System.EventArgs e)
{
flag2 = 1;
flag1 = 0;
Timer1.Enabled = false;
if (MSComm1.PortOpen == false) {
MSComm1.PortOpen = true;
}
MSComm1.Output = Strings.Chr(27) + "p";
TextBox1.Text = Strings.Chr(27) + "p";
do {
Application.DoEvents();
if (flag1 == 1)
goto 10;
}
while (!(MSComm1.InBufferCount >= 13));
a = MSComm1.Input;
Label1.Text = Strings.Mid(a, 1, 9);
Label2.Text = Strings.Mid(a, 10, 3);
10:
if (MSComm1.PortOpen == true)
MSComm1.PortOpen = false;
}
{
int flag2 = 1;
int flag1 = 0;
string a = "";
timer1.Enabled = false;
if (axMSComm1.PortOpen == false)
{
axMSComm1.PortOpen = true;
}
axMSComm1.Output = (char)27 + "p";
//axMSComm1.Output = Strings.Chr(27) + "p";
//TextBox1.Text = Strings.Chr(27) + "p";
do
{
Application.DoEvents(); if (flag1 == 1)
goto L10;
}
while (!(axMSComm1.InBufferCount >= 13));
a = (string)axMSComm1.Input;
label1.Text = a.Substring (1, 9);
label2.Text = a.Substring (10, 3);
L10:
if (axMSComm1.PortOpen == true)
axMSComm1.PortOpen = false; }