Results 1 to 4 of 4

Thread: Picking Out Specific Lines In Console

  1. #1

    Thread Starter
    Lively Member kshadow22's Avatar
    Join Date
    Dec 2014
    Location
    Kentucky
    Posts
    95

    Picking Out Specific Lines In Console

    So I made a Console Application. In it has a user setting. In this setting looks like:
    1(Empty)
    2(Empty)
    3(Empty)
    4(Empty)
    5(Empty)
    6(Empty)
    I Want the user to be able to edit the specific lines in this setting. I don't think it is possible to do this in the settings so if there is another way, please help me. I don't know how to get or change a specific line. I tried:
    Console.WriteLine(My.Settings.UserContent.Line1) <-But it obviously did not work because you can not get lines like that from the settings.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Picking Out Specific Lines In Console

    That setting is presumably a String, so it presumably contains line breaks. In that case, you can split that single String into an array of substrings on those line breaks, e.g.
    Code:
    Dim lines As String() = My.Settings.UserContent.Split({Environment.NewLine}, StringSplitOptions.None)
    After editing individual lines, you can put the lot back together using String.Join.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member kshadow22's Avatar
    Join Date
    Dec 2014
    Location
    Kentucky
    Posts
    95

    Re: Picking Out Specific Lines In Console

    awesome. Thank you!!!!

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Picking Out Specific Lines In Console

    I just noticed that you are using VB 2008. In that case, you would have to be explicit about creating the array for the first argument, i.e.:
    Code:
    Dim lines As String() = My.Settings.UserContent.Split(New String() {Environment.NewLine}, StringSplitOptions.None)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width