#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0

    Problem with ListBox


    Hi i have some problem with my ListBox, after I've browsed a txt file by means of OpenFileDialog to ListBox, all words except the 1-st one are preceded by "square". I don't know how to fix it. Maybe you have any ideas....

    (When I open it in RichTextBox it's all fine no square or something)

    This is my code:
    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
    OpenFileDialog1.ShowDialog() 
    streamer = IO.File.OpenText(OpenFileDialog1.FileName)
    Dim mystring() As String = streamer.ReadToEnd.Split(vbNewLine)
     ListBox1.Items.AddRange(mystring) 
    End Sub
    My text file and Screen:
    Code:
    http://speedy.sh/UXgrd/file.rar
    This code have been testing on another computer and worked, so I didn't have any ideas to resolve my problem.
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,449
    Rep Power
    4539
    Usually a strange character indicates some kind of encoding mismatch, like a utf8 character in an ascii control.

    It's hard to look at your code when it's all on one line.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0
    Ok sorry, now it's better.

    I have a solution (i've changed my code a little bit)

    Now now looks like this:

    Code:
    OpenFileDialog1.ShowDialog() 
    streamer = IO.File.OpenText(OpenFileDialog1.FileName) 
    Dim delimiters() As Char = New Char() {vbCr, vbLf} 
    Dim mystring() As String = streamer.ReadToEnd.Split(delimiters, StringSplitOptions.RemoveEmptyEntries) 
    ListBox1.Items.AddRange(mystring)


    I have this:

    Code:
    ListBox1.SelectedIndex = 0 
    Dim login As String = ListBox1.SelectedItem.ToString.Split(":")(0) 
    Dim hasło As String = ListBox1.SelectedItem.ToString.Split(":")(1) 
    WebBrowser1.Document.GetElementById("log").SetAttribute("value", login) 
    WebBrowser1.Document.GetElementById("pwd").SetAttribute("value", hasło) 
    WebBrowser1.Document.GetElementById("wp-submit").InvokeMember("click")
    Now nicely put in field of the login and password information that is in the first listbox (They are separated by ":" ex login:password)
    Only now I do not know how to do loops to repeat this action , until it logged in or address will change. :/

IMN logo majestic logo threadwatch logo seochat tools logo