locked
Add Remove Quotes in URL String RRS feed

  • Question

  • Hi all i need some help i am newbie
    I made a simple gui whit
    Button1
    and
    Button2
    i need to add option for
    Burron1 
    when click open file dialog and i mark a text file
    in this file i have url string in this order
    http://www.xxx.com
    http://www.xxx.com
    i need to add quotes on front and end
    "http://www.xxx.com"
    "http://www.xxx.com"
    and autosave
    -------------------------------------------
    For Button2
    I need reversion option
    from
    "http://www.xxx.com"
    "http://www.xxx.com"
    to
    http://www.xxx.com
    http://www.xxx.com
    and autosave

    This is my first project and i need yours help.

    Best regards Mr.Dimitrov

    Thanks in advance  .

    Tuesday, February 17, 2009 12:57 PM

Answers

  • try this fto open and add quotes:

    Dim ofd As New OpenFileDialog  
            Dim LineOfText As String = "" 
     
            ofd.ShowDialog()  
     
            FileOpen(1, ofd.FileName, OpenMode.Input)  
            Do Until EOF(1)  
                LineOfText = LineInput(1)  
                LineOfText = Trim(LineOfText)  
                If LineOfText.Length > 0 Then  
                    LineOfText = Chr(34) & LineOfText & Chr(34)  
                    ListBox1.Items.Add(LineOfText)  
                End If  
            Loop  
            FileClose(1)  
     
            FileOpen(1, ofd.FileName, OpenMode.Output)  
            For Each Item As Object In ListBox1.Items  
                PrintLine(1, Item.ToString)  
            Next  
            FileClose(1) 

    I'll work on the reverse





    • Proposed as answer by jwavila Tuesday, February 17, 2009 7:01 PM
    • Marked as answer by dima2000 Wednesday, February 18, 2009 5:06 AM
    Tuesday, February 17, 2009 4:13 PM
  • try this to remove the quotes:

    Dim ofd As New OpenFileDialog  
            Dim LineOfText As String = "" 
            Dim length As Integer = 0 
     
            ofd.ShowDialog()  
     
            FileOpen(1, ofd.FileName, OpenMode.Input)  
            Do Until EOF(1)  
                LineOfText = LineInput(1)  
                LineOfText = Trim(LineOfText)  
                length = LineOfText.Length - 1  
                LineOfTextLineOfText = LineOfText.Remove(length, 1)  
                LineOfTextLineOfText = LineOfText.Remove(0, 1)  
                ListBox1.Items.Add(LineOfText)  
            Loop  
            FileClose(1)  
     
            FileOpen(1, ofd.FileName, OpenMode.Output)  
            For Each Item As Object In ListBox1.Items  
                PrintLine(1, Item.ToString)  
            Next  
            FileClose(1) 

    Might be a stupid question: why add the quotes and save, then remove the quotes and save? Just wondering why you're reversing the same process.

    hope this works for you
    jwavila
    • Proposed as answer by jwavila Tuesday, February 17, 2009 7:01 PM
    • Marked as answer by dima2000 Wednesday, February 18, 2009 5:07 AM
    Tuesday, February 17, 2009 5:09 PM
  • Add a Listbox to your form - this will show you the new data, but it will also save automatically to the file. If you don't want to see it, just set the ListBox1.visible property to false in the properties window
    • Marked as answer by dima2000 Wednesday, February 18, 2009 5:07 AM
    Tuesday, February 17, 2009 5:39 PM
  • Sorry, erase one of the LineOfText in LineOfTextLineOfText. When I paste code, it sometimes doubles up things like that, and I don't catch it
    • Marked as answer by dima2000 Wednesday, February 18, 2009 5:07 AM
    Tuesday, February 17, 2009 6:24 PM

All replies

  • try this fto open and add quotes:

    Dim ofd As New OpenFileDialog  
            Dim LineOfText As String = "" 
     
            ofd.ShowDialog()  
     
            FileOpen(1, ofd.FileName, OpenMode.Input)  
            Do Until EOF(1)  
                LineOfText = LineInput(1)  
                LineOfText = Trim(LineOfText)  
                If LineOfText.Length > 0 Then  
                    LineOfText = Chr(34) & LineOfText & Chr(34)  
                    ListBox1.Items.Add(LineOfText)  
                End If  
            Loop  
            FileClose(1)  
     
            FileOpen(1, ofd.FileName, OpenMode.Output)  
            For Each Item As Object In ListBox1.Items  
                PrintLine(1, Item.ToString)  
            Next  
            FileClose(1) 

    I'll work on the reverse





    • Proposed as answer by jwavila Tuesday, February 17, 2009 7:01 PM
    • Marked as answer by dima2000 Wednesday, February 18, 2009 5:06 AM
    Tuesday, February 17, 2009 4:13 PM
  • try this to remove the quotes:

    Dim ofd As New OpenFileDialog  
            Dim LineOfText As String = "" 
            Dim length As Integer = 0 
     
            ofd.ShowDialog()  
     
            FileOpen(1, ofd.FileName, OpenMode.Input)  
            Do Until EOF(1)  
                LineOfText = LineInput(1)  
                LineOfText = Trim(LineOfText)  
                length = LineOfText.Length - 1  
                LineOfTextLineOfText = LineOfText.Remove(length, 1)  
                LineOfTextLineOfText = LineOfText.Remove(0, 1)  
                ListBox1.Items.Add(LineOfText)  
            Loop  
            FileClose(1)  
     
            FileOpen(1, ofd.FileName, OpenMode.Output)  
            For Each Item As Object In ListBox1.Items  
                PrintLine(1, Item.ToString)  
            Next  
            FileClose(1) 

    Might be a stupid question: why add the quotes and save, then remove the quotes and save? Just wondering why you're reversing the same process.

    hope this works for you
    jwavila
    • Proposed as answer by jwavila Tuesday, February 17, 2009 7:01 PM
    • Marked as answer by dima2000 Wednesday, February 18, 2009 5:07 AM
    Tuesday, February 17, 2009 5:09 PM
  • Thanks jwavila
    I have error can you fix that please.
    Error    Name 'ListBox1' is not declared.   

    Might be a stupid question:
    I have 1 url organizer
    and the stored url data base  use
    this fornat
    "http://www.xxx.com"
    i need to add manualy more url
    or i must add via gui only 1 by 1 link :(


    Tuesday, February 17, 2009 5:33 PM
  • Add a Listbox to your form - this will show you the new data, but it will also save automatically to the file. If you don't want to see it, just set the ListBox1.visible property to false in the properties window
    • Marked as answer by dima2000 Wednesday, February 18, 2009 5:07 AM
    Tuesday, February 17, 2009 5:39 PM
  • Error    1    Name 'LineOfTextLineOfText' is not declared.      line 39   

    Error    2    Name 'LineOfTextLineOfText' is not declared.      line 40   
    Tuesday, February 17, 2009 6:12 PM
  • Sorry, erase one of the LineOfText in LineOfTextLineOfText. When I paste code, it sometimes doubles up things like that, and I don't catch it
    • Marked as answer by dima2000 Wednesday, February 18, 2009 5:07 AM
    Tuesday, February 17, 2009 6:24 PM
  • jwavila

    Ultra thanks i owe you !

    Tested And Work Confirmed :)

    Yes and i have Preview
    ListBox1 :)

    Once again jwavila i remember you help .


    Tuesday, February 17, 2009 6:41 PM