Hack Forums
[.NET] label error in Visual Studio when making a proxy checker - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] label error in Visual Studio when making a proxy checker (/showthread.php?tid=6079547)



label error in Visual Studio when making a proxy checker - Stone - May 19, 2020

I'm new to VB and GUI development in general. I coded a proxy checker. Although the program works, I am getting the following issue with the "Remaining" label and when I try to save, The program does not set the file to be a .txt.

Here is the code:

Code
Imports System.IO

Imports System.Text
Imports System.Net

Public Class Form1
   Dim good, bad, remaining, loaded As Integer

   Private Sub loadbox_TextChanged(sender As Object, e As EventArgs) Handles loadbox.TextChanged
       loadedlabel.Text = "Loaded : " & loadbox.Lines.Count.ToString
       loaded = loadbox.Lines.Count
   End Sub

   Private Sub clearb_Click(sender As Object, e As EventArgs) Handles clearb.Click
       loadbox.Text = ""
       goodbox.Text = ""

       remaininglabel.Text = "Remaining : 0"
       loadedlabel.Text = "Loaded : 0"
       goodlabel.Text = "Good : 0"
   End Sub

   Private Sub saveb_Click(sender As Object, e As EventArgs) Handles saveb.Click
       If SaveFileDialog1.ShowDialog = DialogResult.OK Then
           System.IO.File.WriteAllText(SaveFileDialog1.FileName, goodbox.Text)
       End If
   End Sub

   Private Sub SaveFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk

   End Sub

   Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       Control.CheckForIllegalCrossThreadCalls = False
   End Sub

   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles startb.Click
       BackgroundWorker1.RunWorkerAsync()
   End Sub

   Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
       For Each line As String In loadbox.Text.Split(vbCrLf)
           line = line.Replace(vbCr, "").Replace(vbLf, "")
           Try
               Dim ademproxy As WebProxy
               ademproxy = New WebProxy(line)
               Dim request As HttpWebRequest = HttpWebRequest.Create("https://www.google.com")
               request.Proxy = ademproxy
               request.Timeout = 8000
               Dim response As HttpWebResponse = request.GetResponse

               good += 1
               goodbox.Text += line & vbNewLine
               goodlabel.Text = "Good : " & goodbox.Lines.Count - 1


           Catch ex As Exception
               Bad += 1


           End Try
           remaining = loaded - (good + bad)
           remaininglabel.Text = "Remaining : " & remaininglabel.ToString


       Next
       MsgBox("Finished :D | Found :" & good.ToString & "proxies.")
   End Sub
End Class

Here are some screenshots,
[Image: pE9S6.png]

[Image: Captsure.png]


RE: label _error_ in Visual Studio when making a proxy checker - SIM-3991524 - May 19, 2020

Hi, have your code running

[Image: Capture.png]

Lines 24-26 should be
Code
SaveFileDialog1.Filter = "Text Files|*.txt"
        If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
            System.IO.File.WriteAllText(SaveFileDialog1.FileName, goodbox.Text)
        End If

Line 64 should be
Code
remaininglabel.Text = "Remaining : " & remaining.ToString()

With that your app is mostly working. Consider adding multithreading because its slow ;)