How to split data to text boxes when read qr code data ? [Resolved]

Posted by Ahmedsa under C# on 2/19/2017 | Points: 10 | Views : 278 | Status : [Member] | Replies : 1
How to split data to text boxes when read qr code data ?

I work in windows form application c# visual studio 2015

This windows form read data by qr reader device and get it as this formate

30 General Conference of Arab Pharmaceutical Unions
UserName : michel bondq
Country : Egypt
Membership : part

when read qr it give me message above in text file

I created text file and open it by hand and read qr it give me message above

SO THAT

IF i need to read data from device and receive result directly from device in windows form application as following :

textbox1 michel bondq

textbox2 Egypt

textbox3 part

so that my question

if i need to read data directly to windows form how to receive and split data as following :

textbox1 michel bondq

textbox2 Egypt

textbox3 part

if i put cursor mouse in any textbox it read all data in only one textbox

i need to split it to textboxes after every (:) and get value and put in textbox

please help me




Responses

Posted by: Rajnilari2015 on: 2/19/2017 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
@Ahmedsa Sir, Please try this

using System;
using System.Data;
using System.Linq;
using System.Text.RegularExpressions;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{

var inputText = @"30 General Conference of Arab Pharmaceutical Unions
UserName: michel bondq
Country: Egypt
Membership : part";
inputText
.Split(new string[] { "\r\n" }, StringSplitOptions.None)
.Where(s => s.IndexOf(':') != -1)
.Select(s => s.Trim())
.ToList()
.ForEach(line =>
{
var txt = Regex.Split(line, @":");
Console.WriteLine("{0} {1}", txt[0], txt[1]);
});

System.Console.ReadKey();

}
}

}

/*

Result
--------
UserName michel bondq
Country Egypt
Membership part

*/




--
Thanks & Regards,
RNA Team

Ahmedsa, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response