how to keep data comming from Arduino serial written in VB.NET TextBox











up vote
-1
down vote

favorite












I am sending data from arduino to VB.NET app like rfid number to be shown in TextBox3.Text the data transfered without any problem but after showing in TextBox3.text then removed from textbox and i want it to be in textbox no delete it until I delete it. How can I achieve this?



Arduino Code:



#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.

void setup()
{
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522

}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);

}
delay(5000);

}


and the code in VB.NET is :



  Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
TextBox2.Text = TextBox3.Text

Dim str As String = "Server=localhost;Port=3306;Database=testdb;Uid=root;Pwd=password"


Using con As New MySqlConnection(str)


Dim query As String = "select * from testdatawhere rfid_tag='" & TextBox3.Text & "'
and Date_Operation<= '" & Date.Now.ToString("yyyy-MM-dd ") & "'
and Start_Time<= '" & Date.Now.ToString("HH:mm:ss ") & "'
and End_Time>= '" & Date.Now.ToString("HH:mm:ss ") & "'
or spring_size='' " 'Note:TextBox3 is the RFID number come from RFID arduino
Dim cm As New MySqlCommand(query, con)


con.Open()


Dim rd As MySqlDataReader = cm.ExecuteReader()

' Check if any rows exist
If rd.Read() Then
If rd.GetString(3) = "small" Then
SerialPort1.Write("1")

MessageBox.Show("small")


ElseIf rd.GetString(3) = "Big" Then
SerialPort1.Write("2")

MessageBox.Show("big")

ElseIf rd.GetString(3) = "Midium" Then
SerialPort1.Write("3")

MessageBox.Show("Mid")


End If

End If
End Using
End Sub


and the code for serial connection in VB.NET:



 Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles   Timer1.Tick
receivedData = ReceiveSerialData()
TextBox3.Text = receivedData

End Sub









share|improve this question






















  • I'm not sure I understand your requirement, but try with TextBox3.Appendtext( receivedData)
    – Alessandro Mandelli
    yesterday















up vote
-1
down vote

favorite












I am sending data from arduino to VB.NET app like rfid number to be shown in TextBox3.Text the data transfered without any problem but after showing in TextBox3.text then removed from textbox and i want it to be in textbox no delete it until I delete it. How can I achieve this?



Arduino Code:



#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.

void setup()
{
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522

}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);

}
delay(5000);

}


and the code in VB.NET is :



  Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
TextBox2.Text = TextBox3.Text

Dim str As String = "Server=localhost;Port=3306;Database=testdb;Uid=root;Pwd=password"


Using con As New MySqlConnection(str)


Dim query As String = "select * from testdatawhere rfid_tag='" & TextBox3.Text & "'
and Date_Operation<= '" & Date.Now.ToString("yyyy-MM-dd ") & "'
and Start_Time<= '" & Date.Now.ToString("HH:mm:ss ") & "'
and End_Time>= '" & Date.Now.ToString("HH:mm:ss ") & "'
or spring_size='' " 'Note:TextBox3 is the RFID number come from RFID arduino
Dim cm As New MySqlCommand(query, con)


con.Open()


Dim rd As MySqlDataReader = cm.ExecuteReader()

' Check if any rows exist
If rd.Read() Then
If rd.GetString(3) = "small" Then
SerialPort1.Write("1")

MessageBox.Show("small")


ElseIf rd.GetString(3) = "Big" Then
SerialPort1.Write("2")

MessageBox.Show("big")

ElseIf rd.GetString(3) = "Midium" Then
SerialPort1.Write("3")

MessageBox.Show("Mid")


End If

End If
End Using
End Sub


and the code for serial connection in VB.NET:



 Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles   Timer1.Tick
receivedData = ReceiveSerialData()
TextBox3.Text = receivedData

End Sub









share|improve this question






















  • I'm not sure I understand your requirement, but try with TextBox3.Appendtext( receivedData)
    – Alessandro Mandelli
    yesterday













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I am sending data from arduino to VB.NET app like rfid number to be shown in TextBox3.Text the data transfered without any problem but after showing in TextBox3.text then removed from textbox and i want it to be in textbox no delete it until I delete it. How can I achieve this?



Arduino Code:



#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.

void setup()
{
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522

}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);

}
delay(5000);

}


and the code in VB.NET is :



  Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
TextBox2.Text = TextBox3.Text

Dim str As String = "Server=localhost;Port=3306;Database=testdb;Uid=root;Pwd=password"


Using con As New MySqlConnection(str)


Dim query As String = "select * from testdatawhere rfid_tag='" & TextBox3.Text & "'
and Date_Operation<= '" & Date.Now.ToString("yyyy-MM-dd ") & "'
and Start_Time<= '" & Date.Now.ToString("HH:mm:ss ") & "'
and End_Time>= '" & Date.Now.ToString("HH:mm:ss ") & "'
or spring_size='' " 'Note:TextBox3 is the RFID number come from RFID arduino
Dim cm As New MySqlCommand(query, con)


con.Open()


Dim rd As MySqlDataReader = cm.ExecuteReader()

' Check if any rows exist
If rd.Read() Then
If rd.GetString(3) = "small" Then
SerialPort1.Write("1")

MessageBox.Show("small")


ElseIf rd.GetString(3) = "Big" Then
SerialPort1.Write("2")

MessageBox.Show("big")

ElseIf rd.GetString(3) = "Midium" Then
SerialPort1.Write("3")

MessageBox.Show("Mid")


End If

End If
End Using
End Sub


and the code for serial connection in VB.NET:



 Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles   Timer1.Tick
receivedData = ReceiveSerialData()
TextBox3.Text = receivedData

End Sub









share|improve this question













I am sending data from arduino to VB.NET app like rfid number to be shown in TextBox3.Text the data transfered without any problem but after showing in TextBox3.text then removed from textbox and i want it to be in textbox no delete it until I delete it. How can I achieve this?



Arduino Code:



#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.

void setup()
{
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522

}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);

}
delay(5000);

}


and the code in VB.NET is :



  Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
TextBox2.Text = TextBox3.Text

Dim str As String = "Server=localhost;Port=3306;Database=testdb;Uid=root;Pwd=password"


Using con As New MySqlConnection(str)


Dim query As String = "select * from testdatawhere rfid_tag='" & TextBox3.Text & "'
and Date_Operation<= '" & Date.Now.ToString("yyyy-MM-dd ") & "'
and Start_Time<= '" & Date.Now.ToString("HH:mm:ss ") & "'
and End_Time>= '" & Date.Now.ToString("HH:mm:ss ") & "'
or spring_size='' " 'Note:TextBox3 is the RFID number come from RFID arduino
Dim cm As New MySqlCommand(query, con)


con.Open()


Dim rd As MySqlDataReader = cm.ExecuteReader()

' Check if any rows exist
If rd.Read() Then
If rd.GetString(3) = "small" Then
SerialPort1.Write("1")

MessageBox.Show("small")


ElseIf rd.GetString(3) = "Big" Then
SerialPort1.Write("2")

MessageBox.Show("big")

ElseIf rd.GetString(3) = "Midium" Then
SerialPort1.Write("3")

MessageBox.Show("Mid")


End If

End If
End Using
End Sub


and the code for serial connection in VB.NET:



 Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles   Timer1.Tick
receivedData = ReceiveSerialData()
TextBox3.Text = receivedData

End Sub






vb.net arduino-uno






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









Mohammad Khaled

468




468












  • I'm not sure I understand your requirement, but try with TextBox3.Appendtext( receivedData)
    – Alessandro Mandelli
    yesterday


















  • I'm not sure I understand your requirement, but try with TextBox3.Appendtext( receivedData)
    – Alessandro Mandelli
    yesterday
















I'm not sure I understand your requirement, but try with TextBox3.Appendtext( receivedData)
– Alessandro Mandelli
yesterday




I'm not sure I understand your requirement, but try with TextBox3.Appendtext( receivedData)
– Alessandro Mandelli
yesterday












1 Answer
1






active

oldest

votes

















up vote
0
down vote













the issue was in this code



Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles   Timer1.Tick
receivedData = ReceiveSerialData()
TextBox3.Text = receivedData

End Sub


the correct like this:



Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles   Timer1.Tick
receivedData &= ReceiveSerialData()
TextBox3.Text &= receivedData

End Sub


I missed & to put it before =






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372615%2fhow-to-keep-data-comming-from-arduino-serial-written-in-vb-net-textbox%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    the issue was in this code



    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles   Timer1.Tick
    receivedData = ReceiveSerialData()
    TextBox3.Text = receivedData

    End Sub


    the correct like this:



    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles   Timer1.Tick
    receivedData &= ReceiveSerialData()
    TextBox3.Text &= receivedData

    End Sub


    I missed & to put it before =






    share|improve this answer

























      up vote
      0
      down vote













      the issue was in this code



      Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles   Timer1.Tick
      receivedData = ReceiveSerialData()
      TextBox3.Text = receivedData

      End Sub


      the correct like this:



      Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles   Timer1.Tick
      receivedData &= ReceiveSerialData()
      TextBox3.Text &= receivedData

      End Sub


      I missed & to put it before =






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        the issue was in this code



        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles   Timer1.Tick
        receivedData = ReceiveSerialData()
        TextBox3.Text = receivedData

        End Sub


        the correct like this:



        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles   Timer1.Tick
        receivedData &= ReceiveSerialData()
        TextBox3.Text &= receivedData

        End Sub


        I missed & to put it before =






        share|improve this answer












        the issue was in this code



        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles   Timer1.Tick
        receivedData = ReceiveSerialData()
        TextBox3.Text = receivedData

        End Sub


        the correct like this:



        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles   Timer1.Tick
        receivedData &= ReceiveSerialData()
        TextBox3.Text &= receivedData

        End Sub


        I missed & to put it before =







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        Mohammad Khaled

        468




        468






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372615%2fhow-to-keep-data-comming-from-arduino-serial-written-in-vb-net-textbox%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

            ts Property 'filter' does not exist on type '{}'

            mat-slide-toggle shouldn't change it's state when I click cancel in confirmation window