---
title: "when split msg variable to more lines it not give me values in lines?"  
description: "when split msg variable to more lines it not give me values in lines?"  
author: "Abeer Shlby"  
published: 2017-02-24  
updated: 2017-02-24  
canonical: https://www.mindstick.com/forum/34267/when-split-msg-variable-to-more-lines-it-not-give-me-values-in-lines  
category: "c#"  
tags: ["c#", ".net"]  
reading_time: 3 minutes  

---

# when split msg variable to more lines it not give me values in lines?

**Problem**\
\
**When split msg [variable](https://www.mindstick.com/articles/1807/objective-c-data-types-variables-object-creation) to more lines it not give me values in lines ?\
msg variable in debug give me text scanning bellow**\
\
**Details**\
\
i work in [windows](https://www.mindstick.com/articles/311752/how-to-install-and-use-the-google-wifi-software-on-a-windows-or-mac-computer) form c# vs 2015\
\
i using bar code reader to read [qr code](https://www.mindstick.com/blog/304218/the-rise-of-qr-code-phishing-attacks)\
\
bar [code scanner](https://answers.mindstick.com/qa/116487/wifi-qr-code-scanner-a-smart-way-to-connect-instantly) working as USB [keyboard](https://www.mindstick.com/forum/23117/android-soft-keyboard-close-hide) and define as HID Drivers\
\
if i replace msg variable with text box it working in read data and spiting\
\
[SUCCESS](https://www.mindstick.com/articles/12957/best-tips-to-make-your-ghostwriting-experience-a-success) so that\
\
what is the problem in splitting below code ?\
\
text scanning :\
\
30 General [Conference](https://www.mindstick.com/blog/11886/must-haves-conference-room-facilities-to-plan-a-corporate-event) of Arab Pharmaceutical Unions\
\
[UserName](https://www.mindstick.com/forum/12798/there-is-no-viewdata-item-of-type-ienumerable-selectlistitem-that-has-the-key-username) : khalid ramzy\
\
[Country](https://yourviews.mindstick.com/view/85543/do-you-think-that-french-will-be-islamic-country) : Saudia\
\
[Membership](https://www.mindstick.com/interview/2228/in-which-database-is-the-information-such-as-membership-role-management-profile-and-web-parts-personalization-stored) : part\
\
Serial : 1014\
\
**my code**

```
public partial class Form1 : Form
    {
        DateTime _lastKeystroke = new DateTime(0);
        List<char> _barcode = new List<char>(10);
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            TimeSpan elapsed = (DateTime.Now - _lastKeystroke);
            if (elapsed.TotalMilliseconds > 100)
                _barcode.Clear();
            // record keystroke & timestamp
            _barcode.Add(e.KeyChar);
            _lastKeystroke = DateTime.Now;
            // process barcode
            if (e.KeyChar == 13 && _barcode.Count > 0)
            {
                    string msg = new String(_barcode.ToArray());
                string[] lines = msg.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                if (lines.Length > 5)
                {
                    string msg1 = lines[1].Substring(lines[1].IndexOf(":") + 1);
                    label3.Text = msg1;
                    string msg2 = lines[2].Substring(lines[2].IndexOf(":") + 1);
                    label4.Text = msg2;
                    string msg3 = lines[3].Substring(lines[3].IndexOf(":") + 1);
                    label5.Text = msg3;
                    string msg4 = lines[4].Substring(lines[4].IndexOf(":") + 1);
                    label6.Text = msg4;
                    label2.Text = lines[5].Substring(lines[5].IndexOf(":") + 1);
                }
                    _barcode.Clear();
            }
        }
    }
} 
```

\

msg variable in debug have values of scanning qr code\
\
but problem now\
\
**How to split them to lines as above ?**


---

Original Source: https://www.mindstick.com/forum/34267/when-split-msg-variable-to-more-lines-it-not-give-me-values-in-lines

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
