May 30, 2015 04:24 AM
(This post was last modified: May 30, 2015 05:08 AM by Khamul.)
Ok so I made a Pastebin grabber (without using 'http://pastebin.com/raw.php?i=') just to try and learn a few things about regex, string arrays and various other things... Pretty dumb I know but on the upside it does work!
Example:
Code (Yes it is going to be shitty, also just forget the fact I used multithreading and only used 1 thread, it was because I was just experimenting with multithreading then had the idea for this app):
Code Imports System.IO
Imports System.Net
Public Class Form1
Dim thread1 As System.Threading.Thread
Private Sub leach1()
If ListBox1.Items.Count <> 0 Then
Dim sourcestring As String = New WebClient().DownloadString("http://" & ListBox1.Items.Item(0))
Dim index As Integer = sourcestring.LastIndexOf("</textarea>")
Dim string2 As String = sourcestring.Remove(index)
Dim output As String = string2.Substring(string2.LastIndexOf("event)") + 8)
Dim array() As String = output.Split(Environment.NewLine)
Label1.Text = "Status: Grabbing Paste..."
For Each line As String In array
TextBox1.AppendText(CStr(line & Environment.NewLine))
Next
Label1.Text = "Status: Finnished!"
Else
MessageBox.Show("Please enter a URL!", "No URL entered", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
Private Sub exportpaste()
If TextBox1.Text <> "" Then
Dim svdlg As SaveFileDialog = New SaveFileDialog
svdlg.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
svdlg.ShowDialog()
Dim sw As StreamWriter = New StreamWriter(svdlg.FileName)
sw.Write(TextBox1.Text)
sw.Close()
Else
MessageBox.Show("No paste data to export!", "No data to export!", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
ListBox1.Items.Clear()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Add_URL.Show()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
thread1 = New System.Threading.Thread(AddressOf leach1)
thread1.Start()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.CheckForIllegalCrossThreadCalls = False
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
TextBox1.Clear()
Label1.Text = "Status: Idle"
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
exportpaste()
End Sub
End Class
Anyone have any useful project ideas that I could have a go at to try and improve? I'm very new to VB btw...
Some ideas:
- Chat spammer
- Facebook, Twitter... account creator
- Screen Capture
- Assembly and icon changer
- Email Bomber
DO NOT DEAL WITH THIS MEMBER
Please post your code, we can't really tell you where to improve, if we can't see anything else than the design.
(May 30, 2015 04:42 AM)Nicktron Wrote: Please post your code, we can't really tell you where to improve, if we can't see anything else than the design.
Ok I have done. Let me know what I have done wrong!
DO NOT DEAL WITH THIS MEMBER
May 30, 2015 05:19 AM
(This post was last modified: May 30, 2015 05:21 AM by Nicktron.)
First of all, when you work with threads, import "System.Threading".
Second, don't set Me.CheckForIllegalCrossThreadCalls to false. Google on how to use delegates.
Third, this line: "TextBox1.AppendText(CStr(line & Environment.NewLine))" it is not necessary to use CStr, it could be: TextBox1.AppendText(line & Environment.NewLine)
Thats all I have for a quick look. :)
Also this is fine for a beginner, I must say.
DO NOT DEAL WITH THIS MEMBER
(May 30, 2015 04:32 AM)Neos07 Wrote: Some ideas:
- Chat spammer
- Facebook, Twitter... account creator
- Screen Capture
- Assembly and icon changer
- Email Bomber
Don't make a tool that does this all in one. It would be horrible.
(May 30, 2015 05:19 AM)Nicktron Wrote: First of all, when you work with threads, import "System.Threading".
Second, don't set Me.CheckForIllegalCrossThreadCalls to false. Google on how to use delegates.
Third, this line: "TextBox1.AppendText(CStr(line & Environment.NewLine))" it is not necessary to use CStr, it could be: TextBox1.AppendText(line & Environment.NewLine)
Thats all I have for a quick look. :)
Also this is fine for a beginner, I must say.
Thanks for your feedback, About the 'Cstr' thing, people have said using this is a good habit but I guess since 'line' is already declared as a string it's not needed.
DO NOT DEAL WITH THIS MEMBER
(May 30, 2015 06:17 AM)Khamul Wrote: Thanks for your feedback, About the 'Cstr' thing, people have said using this is a good habit but I guess since 'line' is already declared as a string it's not needed.
My pleasure 🤝
Also I don't see why it would be a good habit, since it's already a string as you said. :)
DO NOT DEAL WITH THIS MEMBER
I was preparing to write up a huge response because I see a lot that can be improved on, until I saw this:
(May 30, 2015 04:24 AM)Khamul Wrote: I'm very new to VB btw...
Someone very new should not be working with IO, networking, Regex (even though I can't see it in the code you provided), and threads.
I'm guessing you kind of glided your way through the project with the help of the internet for each problem you ran in to and slushed each snippet together, correct? This is an awful way to program so I'd suggest channeling your ambitions into learning from the start.
(May 30, 2015 06:17 AM)Khamul Wrote: Thanks for your feedback, About the 'Cstr' thing, people have said using this is a good habit but I guess since 'line' is already declared as a string it's not needed.
My guess is they mean it's a good habit to work with Option Strict on. Btw Calling CStr/ToString() explicitly is redundant when using the & operator since it implicitly converts the operands it's concatenating to their string type representations.
May 30, 2015 08:37 AM
(This post was last modified: May 30, 2015 08:43 AM by Khamul.)
(May 30, 2015 08:21 AM)Odus Wrote: I was preparing to write up a huge response because I see a lot that can be improved on, until I saw this:
Someone very new should not be working with IO, networking, Regex (even though I can't see it in the code you provided), and threads.
I'm guessing you kind of glided your way through the project with the help of the internet for each problem you ran in to and slushed each snippet together, correct? This is an awful way to program so I'd suggest channeling your ambitions into learning from the start.
My guess is they mean it's a good habit to work with Option Strict on. Btw Calling CStr/ToString() explicitly is redundant when using the & operator since it implicitly converts the operands it's concatenating to their string type representations.
Thanks for the feedback, I kind of have tried 'learning from the start' and this was the first real 'project' I have attempted... I did get a few snippets from other people and I know that's not a great way to do things but I'd say most of the code I didn't know before this I got from MSDN and adapted it to my needs... I'm going to buy a few books so I can have a reference of some of the basics that I sometimes forget...I might just wait until September when I start my Computer Science degree at university.
If you are new to vb you should start with console applications. Try making a simple console calculator.
Lotta blood to let, peace to make, give a fuk about a check
DO NOT DEAL WITH THIS MEMBER
(May 30, 2015 08:42 AM)BahNahNah Wrote: If you are new to vb you should start with console applications. Try making a simple console calculator.
Why console? A GUI for a calculator is not hard at all.
(May 30, 2015 08:43 AM)Ninja Wrote: Why console? A GUI for a calculator is not hard at all.
It is for someone who has just started vb.
Lotta blood to let, peace to make, give a fuk about a check
(May 30, 2015 08:43 AM)Ninja Wrote: Why console? A GUI for a calculator is not hard at all.
Sorry guys for the confusion, I'm new to VB as in I've been trying to learn on and off for about a month and a bit...I've already made a GUI calculator but thanks for the suggestion.
|