如何在读取qr代码数据时将数据拆分为文本框? [英] How to split data to text boxes when read qr code data ?

查看:58
本文介绍了如何在读取qr代码数据时将数据拆分为文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在读取qr代码数据时将数据拆分为文本框?



我在windows窗体应用程序中工作c#visual studio 2015



此窗口表格由qr读取器设备读取数据并将其作为此格式化获得



30大会阿拉伯制药联盟

用户名:michel bondq

国家:埃及

会员资格:部分



读取时它会在文本文件中给我上面的消息



我创建了文本文件并手动打开并阅读qr它给我上面的消息



SO THAT



如果我需要从设备读取数据并直接从Windows窗体应用程序中的设备接收结果以下:



textbox1 michel bondq



textbox2埃及



textbox3 part



这样我的问题



如果我需要直接读取数据到windows形成如何接收和分割数据如下:



textbox1 michel bondq



textbox2埃及



textbox3 part



如果我把光标鼠标放在任何文本框中它只读取一个文本框中的所有数据



i需要在每次(:)之后将其拆分为文本框并获取值并放入文本框中



请帮助我



我尝试过:



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

What I have tried:

How to split data to text boxes when read qr code data ?

推荐答案

将文件作为行数组读取:File.ReadAllLines将执行此操作如果您的硬件可以直接处理文件,或者您可以直接处理QR数据。

然后对于每一行,只需使用string.Split打破它:

Read the file as an array of lines: File.ReadAllLines will do that for you from a file, or you can process the QR data directly if that is possible with your hardware.
Then for each line, just use string.Split to break it:
string thisLine = "UserName : michel bondq";
string[] parts = thisLine.Split(':');
if (parts.Length > 1)
   {
   textBox1.Text = parts[1];
   }


这篇关于如何在读取qr代码数据时将数据拆分为文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆