getting delimeted value from the list value
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: getting delimeted value from the list value

  1. #1
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    getting delimeted value from the list value

    Hi Friends,i want to add list of barcode in the textbox .which have multiline true .so what i want . i want to store all the textbox data in list mydelimeter list .i simple want when user click on button it needs to show in attached format.
    let me know please .
    01772531
    01772579
    01775228
    01777710
    01783247
    01812060
    01813005
    01813050
    01515206
    01532104
    01538793
    01548211
    01569025
    01569049
    01569070
    01569742
    03146972
    03147009
    03147320
    03147344
    03147399
    03148600
    03148655
    04697039
    04697046
    04697053
    04697060
    04771098
    04771104
    04771111
    08799005
    08799012
    04914327
    04914334
    04914341
    04914358
    04927808
    04927815
    04927822
    08801005
    08801012
    04767459
    Code:
     private void button1_Click(object sender, EventArgs e){
                List<string> Mydelimeter = new List<string>();
                Mydelimeter.Add(textBox1.Text);
                MessageBox.Show(textBox1.Text);
    
    
            }
    Attached Images Attached Images  
    Last edited by firoz.raj; April 1st, 2013 at 05:06 PM.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,440

    Re: getting delimeted value from the list value

    Not sure what you are asking and it's not clear how you are storing your data. If it were me, I would simply store each entry in a List<string> without any format characters. The to present it, I would loop through the list and add the quotes, commas and new line chars. If you need to append to the list, append it (in raw form) and the read the list to repopulate the multi-line text box (if that's what you are trying to do).

  3. #3
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Re: getting delimeted value from the list value

    it's not clear how you are storing your data.
    i am storing date in list collection only .i don't want to save the list of barcode permanently in the database

    i simple want user will write no of barcode as much as he want in the text box .because we are retail Co .here and as usual we are checking a list of barcode .when
    new shipment has come from the foreign. i am simple taking a list of barcode in toad and checking with sql statment .whether this barcode is available
    in oracle RMS .if not available whe are creating that one by insert statement .so i simple want here to write all the barcode in the text box .and when
    user click on button it shows in attached way .so that i simple copy from the delimeted text from the second text box.and write in in clause of select statment .instead of
    manually do it one by one .First,i have been trying to implement .why it says system.strings. when i press the button .first i want to test in winform of vb.net before test in c#.
    Code:
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim Mydelimeter As New List(Of String)
            Dim x() As String = Split(TextBox1.Text, vbCrLf)
            For i As Integer = 0 To x.Count - 1
                Mydelimeter.Add("'" & x.ToString & "',")
            Next
            'For Each DEL In Mydelimeter
            '    MessageBox.Show(DEL)
            'Next
    
            For i As Integer = Mydelimeter.Count - 1 To 0 Step -1
                'Console.WriteLine(Mydelimeter(i))
                MessageBox.Show(Mydelimeter(i))
            Next i
    
        End Sub
    End Class
    Name:  Issue.jpg
Views: 16
Size:  29.4 KB

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,440

    Re: getting delimeted value from the list value

    It's still not clear what you are trying to do. Oh well. What's with the VB.Net code? Are you coding in VB.Net? If so, then you should ask your question in the VB.Net forum. That being said, I believe you are making the mistake of storing your data in a text box (or text boxes).

    Rather than doing this, store your data in a List<> and then format each item in the list to display it in the text box(es).

    If you still need help, then create a C# solution, zip it up and post it here. Or, if you prefer VB, create a VB solution and post it to the VB.Net forum.

  5. #5
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Re: getting delimeted value from the list value

    actually i want to adapt the following code in c# .when it will work on vb.net . i would like to prefer to convert in C# . can you tell me
    why i am unable to get all the barcode in textbox2 from mydelimeter collection . let me know please .
    Code:
     Private Sub btshow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btshow.Click
            Dim Mydelimeter As New List(Of String)
            Dim x() As String = Split(TextBox1.Text, vbCrLf)
            For i As Integer = 0 To x.Count - 1
                Mydelimeter.Add("'" + x(i) + "',")
            Next
            For Each DEL In Mydelimeter
                TextBox2.Text = DEL
            Next
    
            'For n As Integer = Mydelimeter.Count - 1 To 0 Step -1
            '    'Console.WriteLine(Mydelimeter(i))
            '    TextBox2.Text = Mydelimeter(n)
            'Next n
        End Sub
    End Class









    Name:  issue.jpg
Views: 13
Size:  41.4 KB
    Attached Images Attached Images  
    Last edited by firoz.raj; April 8th, 2013 at 04:33 PM.

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,440

    Re: getting delimeted value from the list value

    I've created a very simple app with a listbox, a textbox and show and clear buttons.

    The listbox is populated from a List<string> which contains unformatted barcode entries.

    When the user presses the 'Show' button, the List<string> items are enumerated. Each item
    gets quoted (i.e. 1234567 becomes '1234567') and appended with a comma to form a string.
    The string is then set to populate the text box.

    IMPORTANT: Notice that I don't enumerate the listbox items directly, but only act on the
    underlying List<string> collection? Even though my simple example doesn't do this, it's often
    easier to perform work on a collection (add, remove, etc) and rebinding the collection
    rather than trying to manipulate listbox items directly.

    The following code illustrates the formatting of the string.
    Code:
    private void _showButton_Click(object sender, EventArgs e)
            {
                ClearTextbox();
    
                var sb = new StringBuilder();
    
                // Loop through the list and create a formatted list
                // string for the text box
    
                foreach (var s in _barcodeList)
                {
                    sb.AppendFormat("\'{0}\',\r\n", s);
                }
                // Remove the last quote and new line chars
                sb.Remove(sb.Length - 3 - 1, 3);
    
                // Assign the formatted barcode text to the text box
                _barcodeTextbox.Text = sb.ToString();
            }
    See the attached sample project.
    Attached Files Attached Files
    Last edited by Arjay; April 9th, 2013 at 01:02 AM.

  7. #7
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,440

    Re: getting delimeted value from the list value

    With regard to the pm about not being able to open the solution, it's a 2012 solution. To open this in Visual Studio 2010, just open the solution as a file (File\Open\File) and press the down arrow next to the Open button and choose 'Open with...'. Next choose to open it as a xml file.

    When the solution file opens, you'll see the following entries at the beginning of the file...

    Code:
    Microsoft Visual Studio Solution File, Format Version 12.00
    # Visual Studio 2012
    Just change this to
    Code:
    Microsoft Visual Studio Solution File, Format Version 11.00
    # Visual Studio 2010
    and you'll be able to open the solution in VS 2010.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center