none
filtered reading from a txt file RRS feed

  • Question

  • I wanna read out a txt file and save the part of a line into my.settings
    e.g.

    Projects Boudrate = 9600

    I want to get these 9600 into the my.settings, how can I filter it from that what I am reading?

    So far I am playing with the idea of "splitting" - does anyone have a better solution?
    Friday, February 13, 2009 8:14 AM

Answers

  • Is that on a line by it's self ? There are several ways to do it for example you can get the string and use the replace function and trim function . Replace Projects Boudrate = with an empty string and trim the string leaving just the number .

       
    Dim S As String = "Projects Boudrate = 9600" 
            MessageBox.Show(Trim(S.Replace("Projects Boudrate = "String.Empty)))  
     


    Coding for fun
    • Edited by bdbodger Friday, February 13, 2009 8:35 AM Added code
    • Marked as answer by Roback33 Friday, February 13, 2009 3:06 PM
    Friday, February 13, 2009 8:29 AM
  • Dim str As String = "Projects Boudrate = 9600"
            Dim value As Integer = Integer.Parse(str.Substring(str.IndexOf("=") + 1))
    Arjun Paudel
    • Marked as answer by Roback33 Friday, February 13, 2009 3:06 PM
    Friday, February 13, 2009 8:52 AM

All replies

  • Is that on a line by it's self ? There are several ways to do it for example you can get the string and use the replace function and trim function . Replace Projects Boudrate = with an empty string and trim the string leaving just the number .

       
    Dim S As String = "Projects Boudrate = 9600" 
            MessageBox.Show(Trim(S.Replace("Projects Boudrate = "String.Empty)))  
     


    Coding for fun
    • Edited by bdbodger Friday, February 13, 2009 8:35 AM Added code
    • Marked as answer by Roback33 Friday, February 13, 2009 3:06 PM
    Friday, February 13, 2009 8:29 AM
  • yes, its a line by itself. your idea soulds good and logical. how can I tell the machine to replace everything until the "="
    Friday, February 13, 2009 8:48 AM
  • Dim str As String = "Projects Boudrate = 9600"
            Dim value As Integer = Integer.Parse(str.Substring(str.IndexOf("=") + 1))
    Arjun Paudel
    • Marked as answer by Roback33 Friday, February 13, 2009 3:06 PM
    Friday, February 13, 2009 8:52 AM
  • thanks, its working
    Friday, February 13, 2009 3:08 PM