How can I split tag number of rfid as integer?How to check if a number is a power of 2How can I get the application's path in a .NET console application?How can I generate random alphanumeric strings?How do I generate a random int number?Calculate distance to RFID tag?Visual C# Programming a Login form connected to a Access Db that gives only tries to log intoC# method failing to function for no known reasonHow can I get the serial number printed on RFID tag with RFID reader?Simple addition string to int with C#Save RFID tag no. to mysql

Could there be a material that inverts the colours seen through it?

Why are solar panels kept tilted?

Is 12 minutes connection in Bristol Temple Meads long enough?

What is the best way for a skeleton to impersonate human without using magic?

Is it possible to create different colors in rocket exhaust?

Why did the metro bus stop at each railway crossing, despite no warning indicating a train was coming?

Why would a switch ever send an ARP request for a MAC address when it can just wait for the first packet to be received from a device?

How to distinguish PICTURE OF ME and PICTURE OF MINE in Chinese?

In books, how many dragons are there in present time?

Is Germany still exporting arms to countries involved in Yemen?

Trim trailing zeroes off a number extracted by jq

Is there any good reason to write "it is easy to see"?

correct spelling of "carruffel" (fuzz, hustle, all that jazz)

What to do if SUS scores contradict qualitative feedback?

Ito`s Lemma problem

Program which behaves differently in/out of a debugger

Formal Definition of Dot Product

What information do scammers need to withdraw money from an account?

Tikz draw contour without some edges, and fill

Why do the lights go out when someone enters the dining room on this ship?

CPLD based Pierce oscillator

Is there ever any indication in the MCU as to how Spider-Man got his powers?

As programers say: Strive to be lazy

How exactly does artificial gravity work?



How can I split tag number of rfid as integer?


How to check if a number is a power of 2How can I get the application's path in a .NET console application?How can I generate random alphanumeric strings?How do I generate a random int number?Calculate distance to RFID tag?Visual C# Programming a Login form connected to a Access Db that gives only tries to log intoC# method failing to function for no known reasonHow can I get the serial number printed on RFID tag with RFID reader?Simple addition string to int with C#Save RFID tag no. to mysql






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm getting the information by reading the card, but how can I just get the tag number as int?



 public Form1()

InitializeComponent();


private void Form1_Load(object sender, EventArgs e)

if (!serialPort1.IsOpen)

serialPort1.Open();
serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);


MessageBox.Show("Success");

private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)

Control.CheckForIllegalCrossThreadCalls = false;
SerialPort sp = (SerialPort)sender;
string indata = sp.ReadExisting();
textRFID.Text += indata;



rfid-ss



This is the string I need to parse:



"RFID tag detected Tag Type:tMifare One (S50) The tag's number is:t235717311 Read Checksum:t238 Calculated Checksum:t238"


Thanks to @haldo I can receive my tag number but it gives "object reference not set to an instance of an object" error and I put try catch, when I press ok to error, it goes and output is as I wanted. How can we remove this error?



Here is my editing code :



private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)

Control.CheckForIllegalCrossThreadCalls = false;
string contains = "The tag's number is:";
SerialPort sp = (SerialPort)sender;
string indata = sp.ReadExisting();
int tagNumber = 0;
try

indata.Split(Environment.NewLine.ToCharArray()) // split on newline chars
.FirstOrDefault(s => s.Contains(contains)) // get first string matching pattern above
.Split(':') // split on ':'
.FirstOrDefault(x => int.TryParse(x, out tagNumber)); // return first successful try parse

catch (Exception ex) MessageBox.Show(ex.Message);
textRFID.Text = tagNumber.ToString();










share|improve this question
























  • You could use regex to look for the pattern and capture the group of digits after "The tag's number is:", then parse that captured string as an int.

    – rory.ap
    Mar 23 at 13:42

















0















I'm getting the information by reading the card, but how can I just get the tag number as int?



 public Form1()

InitializeComponent();


private void Form1_Load(object sender, EventArgs e)

if (!serialPort1.IsOpen)

serialPort1.Open();
serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);


MessageBox.Show("Success");

private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)

Control.CheckForIllegalCrossThreadCalls = false;
SerialPort sp = (SerialPort)sender;
string indata = sp.ReadExisting();
textRFID.Text += indata;



rfid-ss



This is the string I need to parse:



"RFID tag detected Tag Type:tMifare One (S50) The tag's number is:t235717311 Read Checksum:t238 Calculated Checksum:t238"


Thanks to @haldo I can receive my tag number but it gives "object reference not set to an instance of an object" error and I put try catch, when I press ok to error, it goes and output is as I wanted. How can we remove this error?



Here is my editing code :



private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)

Control.CheckForIllegalCrossThreadCalls = false;
string contains = "The tag's number is:";
SerialPort sp = (SerialPort)sender;
string indata = sp.ReadExisting();
int tagNumber = 0;
try

indata.Split(Environment.NewLine.ToCharArray()) // split on newline chars
.FirstOrDefault(s => s.Contains(contains)) // get first string matching pattern above
.Split(':') // split on ':'
.FirstOrDefault(x => int.TryParse(x, out tagNumber)); // return first successful try parse

catch (Exception ex) MessageBox.Show(ex.Message);
textRFID.Text = tagNumber.ToString();










share|improve this question
























  • You could use regex to look for the pattern and capture the group of digits after "The tag's number is:", then parse that captured string as an int.

    – rory.ap
    Mar 23 at 13:42













0












0








0








I'm getting the information by reading the card, but how can I just get the tag number as int?



 public Form1()

InitializeComponent();


private void Form1_Load(object sender, EventArgs e)

if (!serialPort1.IsOpen)

serialPort1.Open();
serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);


MessageBox.Show("Success");

private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)

Control.CheckForIllegalCrossThreadCalls = false;
SerialPort sp = (SerialPort)sender;
string indata = sp.ReadExisting();
textRFID.Text += indata;



rfid-ss



This is the string I need to parse:



"RFID tag detected Tag Type:tMifare One (S50) The tag's number is:t235717311 Read Checksum:t238 Calculated Checksum:t238"


Thanks to @haldo I can receive my tag number but it gives "object reference not set to an instance of an object" error and I put try catch, when I press ok to error, it goes and output is as I wanted. How can we remove this error?



Here is my editing code :



private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)

Control.CheckForIllegalCrossThreadCalls = false;
string contains = "The tag's number is:";
SerialPort sp = (SerialPort)sender;
string indata = sp.ReadExisting();
int tagNumber = 0;
try

indata.Split(Environment.NewLine.ToCharArray()) // split on newline chars
.FirstOrDefault(s => s.Contains(contains)) // get first string matching pattern above
.Split(':') // split on ':'
.FirstOrDefault(x => int.TryParse(x, out tagNumber)); // return first successful try parse

catch (Exception ex) MessageBox.Show(ex.Message);
textRFID.Text = tagNumber.ToString();










share|improve this question
















I'm getting the information by reading the card, but how can I just get the tag number as int?



 public Form1()

InitializeComponent();


private void Form1_Load(object sender, EventArgs e)

if (!serialPort1.IsOpen)

serialPort1.Open();
serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);


MessageBox.Show("Success");

private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)

Control.CheckForIllegalCrossThreadCalls = false;
SerialPort sp = (SerialPort)sender;
string indata = sp.ReadExisting();
textRFID.Text += indata;



rfid-ss



This is the string I need to parse:



"RFID tag detected Tag Type:tMifare One (S50) The tag's number is:t235717311 Read Checksum:t238 Calculated Checksum:t238"


Thanks to @haldo I can receive my tag number but it gives "object reference not set to an instance of an object" error and I put try catch, when I press ok to error, it goes and output is as I wanted. How can we remove this error?



Here is my editing code :



private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)

Control.CheckForIllegalCrossThreadCalls = false;
string contains = "The tag's number is:";
SerialPort sp = (SerialPort)sender;
string indata = sp.ReadExisting();
int tagNumber = 0;
try

indata.Split(Environment.NewLine.ToCharArray()) // split on newline chars
.FirstOrDefault(s => s.Contains(contains)) // get first string matching pattern above
.Split(':') // split on ':'
.FirstOrDefault(x => int.TryParse(x, out tagNumber)); // return first successful try parse

catch (Exception ex) MessageBox.Show(ex.Message);
textRFID.Text = tagNumber.ToString();







c# arduino rfid






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 22:25









haldo

2,7791823




2,7791823










asked Mar 23 at 13:34









VornVorn

123




123












  • You could use regex to look for the pattern and capture the group of digits after "The tag's number is:", then parse that captured string as an int.

    – rory.ap
    Mar 23 at 13:42

















  • You could use regex to look for the pattern and capture the group of digits after "The tag's number is:", then parse that captured string as an int.

    – rory.ap
    Mar 23 at 13:42
















You could use regex to look for the pattern and capture the group of digits after "The tag's number is:", then parse that captured string as an int.

– rory.ap
Mar 23 at 13:42





You could use regex to look for the pattern and capture the group of digits after "The tag's number is:", then parse that captured string as an int.

– rory.ap
Mar 23 at 13:42












2 Answers
2






active

oldest

votes


















1














Why don't you use String manipulators like Substring or String.split(''). you would get the Tag number and then use Convert.ToInt(your tag number here) to convert into INT. By default it is string. you need to convert it to Integer






share|improve this answer























  • thanks for advice. I edited my code but now it gives "object reference not set to an instance of an object" error. You've an idea?

    – Vorn
    Mar 23 at 20:55











  • A proper debugging would help. It means that somewhere an object has not been referenced to

    – Apoorv
    Mar 24 at 20:08


















1














You could use regex to look for the pattern and capture the group of digits after "The tag's number is:", then parse that captured string as an int. Something like this:



string pattern = "The tag's number is:(\d+)";
string indata = "blah blah nasdfasdfasdfnThe tag's number is:123389882nasdfsadfnfgjdjgjgd";
var matches = Regex.Match(indata, pattern);
int? tagNumber = null;

if (matches.Success)

var grp = matches.Groups[1];
string num = grp.Value;
tagNumber = int.Parse(num);


// tagNumber is 123389882





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',
    autoActivateHeartbeat: false,
    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%2f55314250%2fhow-can-i-split-tag-number-of-rfid-as-integer%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Why don't you use String manipulators like Substring or String.split(''). you would get the Tag number and then use Convert.ToInt(your tag number here) to convert into INT. By default it is string. you need to convert it to Integer






    share|improve this answer























    • thanks for advice. I edited my code but now it gives "object reference not set to an instance of an object" error. You've an idea?

      – Vorn
      Mar 23 at 20:55











    • A proper debugging would help. It means that somewhere an object has not been referenced to

      – Apoorv
      Mar 24 at 20:08















    1














    Why don't you use String manipulators like Substring or String.split(''). you would get the Tag number and then use Convert.ToInt(your tag number here) to convert into INT. By default it is string. you need to convert it to Integer






    share|improve this answer























    • thanks for advice. I edited my code but now it gives "object reference not set to an instance of an object" error. You've an idea?

      – Vorn
      Mar 23 at 20:55











    • A proper debugging would help. It means that somewhere an object has not been referenced to

      – Apoorv
      Mar 24 at 20:08













    1












    1








    1







    Why don't you use String manipulators like Substring or String.split(''). you would get the Tag number and then use Convert.ToInt(your tag number here) to convert into INT. By default it is string. you need to convert it to Integer






    share|improve this answer













    Why don't you use String manipulators like Substring or String.split(''). you would get the Tag number and then use Convert.ToInt(your tag number here) to convert into INT. By default it is string. you need to convert it to Integer







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 23 at 13:47









    ApoorvApoorv

    1,18611033




    1,18611033












    • thanks for advice. I edited my code but now it gives "object reference not set to an instance of an object" error. You've an idea?

      – Vorn
      Mar 23 at 20:55











    • A proper debugging would help. It means that somewhere an object has not been referenced to

      – Apoorv
      Mar 24 at 20:08

















    • thanks for advice. I edited my code but now it gives "object reference not set to an instance of an object" error. You've an idea?

      – Vorn
      Mar 23 at 20:55











    • A proper debugging would help. It means that somewhere an object has not been referenced to

      – Apoorv
      Mar 24 at 20:08
















    thanks for advice. I edited my code but now it gives "object reference not set to an instance of an object" error. You've an idea?

    – Vorn
    Mar 23 at 20:55





    thanks for advice. I edited my code but now it gives "object reference not set to an instance of an object" error. You've an idea?

    – Vorn
    Mar 23 at 20:55













    A proper debugging would help. It means that somewhere an object has not been referenced to

    – Apoorv
    Mar 24 at 20:08





    A proper debugging would help. It means that somewhere an object has not been referenced to

    – Apoorv
    Mar 24 at 20:08













    1














    You could use regex to look for the pattern and capture the group of digits after "The tag's number is:", then parse that captured string as an int. Something like this:



    string pattern = "The tag's number is:(\d+)";
    string indata = "blah blah nasdfasdfasdfnThe tag's number is:123389882nasdfsadfnfgjdjgjgd";
    var matches = Regex.Match(indata, pattern);
    int? tagNumber = null;

    if (matches.Success)

    var grp = matches.Groups[1];
    string num = grp.Value;
    tagNumber = int.Parse(num);


    // tagNumber is 123389882





    share|improve this answer





























      1














      You could use regex to look for the pattern and capture the group of digits after "The tag's number is:", then parse that captured string as an int. Something like this:



      string pattern = "The tag's number is:(\d+)";
      string indata = "blah blah nasdfasdfasdfnThe tag's number is:123389882nasdfsadfnfgjdjgjgd";
      var matches = Regex.Match(indata, pattern);
      int? tagNumber = null;

      if (matches.Success)

      var grp = matches.Groups[1];
      string num = grp.Value;
      tagNumber = int.Parse(num);


      // tagNumber is 123389882





      share|improve this answer



























        1












        1








        1







        You could use regex to look for the pattern and capture the group of digits after "The tag's number is:", then parse that captured string as an int. Something like this:



        string pattern = "The tag's number is:(\d+)";
        string indata = "blah blah nasdfasdfasdfnThe tag's number is:123389882nasdfsadfnfgjdjgjgd";
        var matches = Regex.Match(indata, pattern);
        int? tagNumber = null;

        if (matches.Success)

        var grp = matches.Groups[1];
        string num = grp.Value;
        tagNumber = int.Parse(num);


        // tagNumber is 123389882





        share|improve this answer















        You could use regex to look for the pattern and capture the group of digits after "The tag's number is:", then parse that captured string as an int. Something like this:



        string pattern = "The tag's number is:(\d+)";
        string indata = "blah blah nasdfasdfasdfnThe tag's number is:123389882nasdfsadfnfgjdjgjgd";
        var matches = Regex.Match(indata, pattern);
        int? tagNumber = null;

        if (matches.Success)

        var grp = matches.Groups[1];
        string num = grp.Value;
        tagNumber = int.Parse(num);


        // tagNumber is 123389882






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 23 at 13:58

























        answered Mar 23 at 13:52









        rory.aprory.ap

        24.2k943110




        24.2k943110



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55314250%2fhow-can-i-split-tag-number-of-rfid-as-integer%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

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현