Favorites

Discussion in 'Programming General' started by kharg0, Mar 4, 2007.

Favorites
  1. Unread #1 - Mar 4, 2007 at 10:20 AM
  2. kharg0
    Joined:
    Feb 25, 2007
    Posts:
    131
    Referrals:
    0
    Sythe Gold:
    0

    kharg0 Active Member

    Favorites

    how do you make a favorites page that can add or remove items on the list and if you double click it it will bring you there???:sad:
     
  3. Unread #2 - Mar 5, 2007 at 3:34 PM
  4. slashshot007
    Joined:
    May 6, 2006
    Posts:
    164
    Referrals:
    0
    Sythe Gold:
    0

    slashshot007 Active Member

    Favorites

    you would probably want to use a txt file. i could probably whip something up later.
     
  5. Unread #3 - Mar 5, 2007 at 4:16 PM
  6. kharg0
    Joined:
    Feb 25, 2007
    Posts:
    131
    Referrals:
    0
    Sythe Gold:
    0

    kharg0 Active Member

    Favorites

    ok i guess that helps
     
  7. Unread #4 - Mar 8, 2007 at 6:11 PM
  8. slashshot007
    Joined:
    May 6, 2006
    Posts:
    164
    Referrals:
    0
    Sythe Gold:
    0

    slashshot007 Active Member

    Favorites

    ok i got one to work: heres the code you need first:

    Code:
        Sub updatelistbox(ByVal file As String, ByVal listbox As ListBox)
            Dim i As String, h As Integer = 1
            file = My.Computer.FileSystem.ReadAllText(file)
            listbox.Items.Clear()
            Do
                i = Split(file, "(&*&)")(h)
                h = h + 1
                If i = "!end" Then Exit Do
                listbox.Items.Add(i.ToString)
            Loop
        End Sub
    
        Sub savelistbox(ByVal listbox As ListBox, ByVal file As String)
            Dim i As Integer, text As String = ""
            My.Computer.FileSystem.DeleteFile(file)
            For i = 0 To ListBox1.Items.Count - 1
                text = text & "(&*&)" & ListBox1.Items.Item(i).ToString
            Next
            My.Computer.FileSystem.WriteAllText(file, text & "(&*&)!end", True)
        End Sub
    

    when you want to add to the listbox, just do this code:
    Code:
    listbox1.add(textbox1.text)
    that saves it to a file called hi.txt, and saves the url from textbox1.text


    now when you want to remove from the listbox do:
    Code:
    listbox1.remove(listbox1.selecteditem)
    that removes the selected item in listbox1

    for saving just do this:
    Code:
    savelistbox(ListBox1, "save.txt")
    for loading do this:
    Code:
    updatelistbox("save.txt", ListBox1)

    now for navigating to the selected listbox url, add this:
    Code:
        Private Sub ListBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseClick
            WebBrowser1.Navigate(ListBox1.SelectedItem)
        End Sub
    in this case the webbrowser is called webbrowser1, and the listbox is called listbox1.


    and there u have it! a working favorites.


    wow i'm becoming a good programmer for being able to do that :p i'm proud of myself.
     
  9. Unread #5 - Mar 8, 2007 at 6:34 PM
  10. cooladrrang
    Joined:
    Jan 21, 2007
    Posts:
    125
    Referrals:
    0
    Sythe Gold:
    0

    cooladrrang Active Member

    Favorites

    what does this do (&*&) and this ("!") or whats your msn im doing a cool project ill add you to credits but it will have to be your reall name beacause its a real program not a auto or *hit lke that this is going to be the cool version tehres one version at download.com
     
  11. Unread #6 - Mar 8, 2007 at 7:10 PM
  12. slashshot007
    Joined:
    May 6, 2006
    Posts:
    164
    Referrals:
    0
    Sythe Gold:
    0

    slashshot007 Active Member

    Favorites

    (&*&) divides the big long string of lots of URLS and stuff into seperate URLs. so in between each url there will be a (&*&).
    and the ! basically signals the ending. so it has split.remove(split.indexof(!)) that will remove all text after the exclamation point.
     
  13. Unread #7 - Mar 8, 2007 at 8:08 PM
  14. cooladrrang
    Joined:
    Jan 21, 2007
    Posts:
    125
    Referrals:
    0
    Sythe Gold:
    0

    cooladrrang Active Member

    Favorites

    omg im a noob at slipiting
     
  15. Unread #8 - Mar 9, 2007 at 6:17 PM
  16. slashshot007
    Joined:
    May 6, 2006
    Posts:
    164
    Referrals:
    0
    Sythe Gold:
    0

    slashshot007 Active Member

    Favorites

    i updated the code lol. this is MUCH more reliable
     
  17. Unread #9 - Mar 9, 2007 at 6:39 PM
  18. Skeletron
    Referrals:
    0

    Skeletron Guest

    Favorites

    SlashShot, why don't you just use StreamReader & StreamWriter, it is 10 times faster?

    It is way better to use Split.Split and VB.net it is way better to use a Split.index of then a Instr, because a Instr is old and an IndexOf seems to operate much faster.

    For favorites you can make it operate much much faster when you add it into a arraylist. So when you close the program, it will add all the values to the .txt in the array. When you start it up, it will load it all into a arraylist from that file and then it will operate using the temp values in the arraylist.

    This method is much faster because when you select a favourite it does not always have to call the streamreader.
     
  19. Unread #10 - Mar 18, 2007 at 7:36 PM
  20. kharg0
    Joined:
    Feb 25, 2007
    Posts:
    131
    Referrals:
    0
    Sythe Gold:
    0

    kharg0 Active Member

    Favorites

    ok thx everyone i was on vacation sory i didn't reply

    oh ya and shot i tried it out one small problem in it wen it says listbox1.add (textbox1.text)

    add is not a member of of listbox
    try this

    Code:
    Me.ListBox1.Items.Add(TextBox1.Text)
    \
    and for remove
    Code:
    Me.ListBox1.Items.Remove(ListBox1.SelectedItem)
     
< How to use progress bars? | SidScape Beta >

Users viewing this thread
1 guest


 
 
Adblock breaks this site