DO NOT DEAL WITH THIS MEMBER
I keep getting this error whenever I am saving my listbox info to a .txt file for some reason..
Could anyone help me out? I've been screwin with it for a couple hours now.
https://gyazo.com/df41710a0ab0d21a08d06cf3dbcfbe84
Code for the saving button:
Code Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Using ofd As New SaveFileDialog() With {.Filter = "Text Files|*.txt"}
If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim sb As New StringBuilder()
For Each item In ListBox1.Items
sb.AppendLine(item.ToString())
Next
IO.File.WriteAllText(ofd.FileName, sb.ToString())
MessageBox.Show("Working proxies have been exported")
End If
End Using
End Sub
Am I missing something here..? It's never given me this problem in any other programs I've used it in.
ListBox1 is probably null, that's the issue
DO NOT DEAL WITH THIS MEMBER
(Feb 21, 2017 05:50 PM)+Haze Wrote: ListBox1 is probably null, that's the issue
How could it be null?
The saving option works fine when there's nothing in the tlist box. But once I have stuff in the list box it will not save.. It saves like 50% of it then gives an error, which I cannot find what that error is.)
Will take a look at this soon for you.
DO NOT DEAL WITH THIS MEMBER
(Feb 21, 2017 05:56 PM)Darrell Wrote: Will take a look at this soon for you.
Sounds good. I'm not trying to be spoon fed, but I've been messing with it for about 4 hours now and no matter how I put it, I get the same error.
I'm assuming I'm getting something in my list box that is not being able to be saved.
Would anyone know how to only allow certain things in a list box?
you have a null string or object in the listbox
DO NOT DEAL WITH THIS MEMBER
(Feb 21, 2017 05:59 PM)redmoon90211 Wrote: you have a null string or object in the listbox
I am now trying to figure out how to remove only things that are not numbers or the ":" sign.
DO NOT DEAL WITH THIS MEMBER
Feb 21, 2017 06:08 PM
(This post was last modified: Feb 21, 2017 06:09 PM by Gt403cyl.)
I'm not sure how to do it in .vb
But a try/catch in the save button with
Code try
{
if (!textbox1.text == null)
{
dostuff();
}
Else
{
}
}
catch (exception error)
{
Messagebox.show("oops", error.ToString());
}
This can be simplified without the try/catch but meh you get the idea.
Just it's in c# so convert it as needed.
(Feb 21, 2017 06:00 PM)Gørilla Wrote: I am now trying to figure out how to remove only things that are not numbers or the ":" sign.
Code For Each item In ListBox1.Items
If item IsNot Nothing Then
sb.AppendLine(item.ToString())
End If
Next
DO NOT DEAL WITH THIS MEMBER
Feb 21, 2017 06:15 PM
(This post was last modified: Feb 21, 2017 06:15 PM by Gørilla.)
(Feb 21, 2017 06:08 PM)redmoon90211 Wrote: Code For Each item In ListBox1.Items
If item IsNot Nothing Then
sb.AppendLine(item.ToString())
End If
Next
Seem to get an error when I try to use this. It's because of the if statement.
(Feb 21, 2017 06:08 PM)Gt403cyl Wrote: I'm not sure how to do it in .vb
But a try/catch in the save button with
Code try
{
if (!textbox1.text == null)
{
dostuff();
}
Else
{
}
}
catch (exception error)
{
Messagebox.show("oops", error.ToString());
}
This can be simplified without the try/catch but meh you get the idea.
Just it's in c# so convert it as needed.
I'll see if I can convert this:)
DO NOT DEAL WITH THIS MEMBER
There maybe errors (disclaimer lol on phone) but the you get the idea..
I didn't see you were using a listbox but should still work just replace as needed.
DO NOT DEAL WITH THIS MEMBER
Feb 21, 2017 06:21 PM
(This post was last modified: Feb 21, 2017 09:45 PM by Gørilla.)
(Feb 21, 2017 06:18 PM)Gt403cyl Wrote: There maybe errors (disclaimer lol on phone) but the you get the idea..
I didn't see you were using a listbox but should still work just replace as needed.
I'm trying to convert it but I want to keep numbers 0-9 in, periods, and semi colens and everything else is to be deleted.
Currently trying to use this on my start thread button:
Code Dim i As Integer = 0
Do While (ListBox1.Items.Count) - 1 >= i
If String.IsNullOrEmpty(ListBox1.Items(i)) Then
ListBox1.Items.Remove(ListBox1.Items(i))
i -= 1
End If
i += 1
Loop
Turns out I had my regex off a tad, and for some reason when using both threads at the same time it returns as null value, assuming it's conjoining some information some how. But spaced them out with a timer and fixed the problem.. It only took me 6 hours but damn it was worth the learning curve. Thanks for all the help guys.
|