Search code examples
c#textboxparseint

Get values from one textbox and put them in another textboxes


I have values from a textbox :

"r, 00.00m,0000521135Hz,0000000000c,0000000.000s, 025.1C"

and I want to make each value show in another textboxes like this:

textbox 1:
a: "00.00"
textbox 2:
b: "0000521135"
textbox 3:
c: "0000000.000"
textbox 4:
d: "025.1"

I can do this in arduino using parseInt(), I wonder how to do this in c#, any help?


Solution

  • you can use a string.split() function to extract value from first textbox.

    string baseStr = "r, 00.00m,0000521135Hz,0000000000c,0000000.000s, 025.1C";
    List<string> colStr= test.Split(new char[','], StringSplitOptions.RemoveEmptyEntries);
    

    and then remove alphabet using regular expression

    using System.Text.RegularExpressions;
    ...
    Textbox1.Text = Regex.Replace(colStr[1], "[A-Za-z]", "");
    Textbox2.Text = Regex.Replace(colStr[2], "[A-Za-z]", ""));
    ...