FREE VB.NET SOURCE CODE

31 March, 2012

[SNP] Disable / Enable Computer CD Burning [VB.NET]

 My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoCDBurning", "1", Microsoft.Win32.RegistryValueKind.DWord)  

This will disable the cd's burning property.
To enable it again, change 1 to 0.
Or use this code:

 My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoCDBurning", "0", Microsoft.Win32.RegistryValueKind.DWord)  

29 March, 2012

[SNP] Disable / Turn Off Windows Firewall [VB.NET]

First add this SUB to your project:

    Private Sub StopFirewall()
        Dim Program As Process = New Process
        Dim top As String = "netsh.exe"
        Program.StartInfo.Arguments = ("firewall set opmode disable")
        Program.StartInfo.FileName = top
        Program.StartInfo.UseShellExecute = False
        Program.StartInfo.RedirectStandardOutput = True
        Program.StartInfo.CreateNoWindow = True
        Program.Start()
        Program.WaitForExit()
    End Sub

Then use it like that:

    StopFirewall()

[SNP] Take Screenshot / Save Screenshot [VB.NET]

  Public Sub TakeScreenshot()  
     Try  
       Dim filename As String = System.Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) & "\SS.gif", ScreenSize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height), screenGrab As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height), g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(screenGrab)  
       g.CopyFromScreen(New Point(0, 0), New Point(0, 0), ScreenSize)  
       If My.Computer.FileSystem.FileExists(System.Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) & "\SS.gif") Then  
         My.Computer.FileSystem.DeleteFile(System.Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) & "\SS.gif")  
       End If  
       screenGrab.Save(filename, System.Drawing.Imaging.ImageFormat.Gif)  
     Catch  
     End Try  
   End Sub  


This is the sub, that will get your screenshot, afterwards use this

TakeScreenshot()  
 My.Computer.FileSystem.MoveFile(System.Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) & "\SS.gif", System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\SS.gif")  

to save your screenshot on your desktop with the name SS.gif

27 March, 2012

[SNP] ListBox Remove item / Clear / Display / Add [VB.NET]

Some useful ListBox codes/examples:

Adding an item:
ListBox1.Items.Add("TEST ITEM")

Remove all items from a ListBox:
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Clear()
'using the clear method to clear the list box
End Sub 

Remove particular item from a ListBox:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e _
As System.EventArgs) Handles Button1.Click
ListBox1.Items.RemoveAt(4)
'removing an item by specifying it's index
End Sub 

Display selected ListBox item, to a TextBox:
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object,_
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
TextBox1.Text = ListBox1.SelectedItem
'using the selected item property
End Sub 

Count all items in a ListBox:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e _
As System.EventArgs) Handles Button1.Click
TextBox1.Text = ListBox1.Items.Count
'counting the number of items in the ListBox with the Items.Count
End Sub

Display ListBox item index:
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
TextBox1.Text = ListBox1.SelectedIndex
'using the selected index property of the list box to select the index
End Sub 

The default ListBox event - selected index changed:
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

End Sub 

[SNP] Using HTTPWebRequests to login to Facebook [VB.NET]

Dim cookieJar As New Net.CookieContainer()
  Dim request As Net.HttpWebRequest
  Dim response As Net.HttpWebResponse
  Dim strURL As String = ""

  Try
    'Get Cookies
    strURL = "https://login.facebook.com/login.php"
    request = CType(HttpWebRequest.Create(strURL), HttpWebRequest)
    request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3"
    request.Method = "GET"
    request.CookieContainer = cookieJar
    response = CType(request.GetResponse(), HttpWebResponse)

    For Each tempCookie As Net.Cookie In response.Cookies
    cookieJar.Add(tempCookie)
    Next

    'Send the post data now
    request = CType(HttpWebRequest.Create(strURL), HttpWebRequest)
    request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3"
    request.Method = "POST"
    request.AllowAutoRedirect = True
    request.CookieContainer = cookieJar

    Dim writer As StreamWriter = New StreamWriter(request.GetRequestStream())
    writer.Write("email=username&pass=password")
    writer.Close()
    response = CType(request.GetResponse(), HttpWebResponse)

    'Get the data from the page
    Dim stream As StreamReader = New StreamReader(response.GetResponseStream())
    Dim data As String = stream.ReadToEnd()
    response.Close()

    If data.Contains("<title>Facebook") = True Then
    'LOGGED IN SUCCESSFULLY
    MessageBox.Show("logged in sucessfully")
    Else
    MessageBox.Show("Not logged in")
    End If

  Catch ex As Exception
    MessageBox.Show(ex.tostring)
  End Try

With this basic HTTPWebRequest you can check if the login details - user and password are correct .

[Link] Download VIsual Studio - IDE for Visual Basic [VB.NET]

For starters, an IDE stands for: Integrated development environment ,wich basicly is "the program" where you program ^^.

So when you finish your programming, it arranges all the files in a strict order and compiles your code in to .exe file.

Currently the best IDE for Visual Basic is Microsoft Visual Studio, that you can download from:

Microsoft Visual Studio 2010 - The Pirate Bay - Mirror #1
Mirror
Microsoft Visual Studio 2010 - The Pirate Bay - Mirror #2
Mirror
Microsoft Visual Studio 2010 - The Pirate Bay - Mirror #3
 Mirror
Microsoft Visual Studio 2010 - Demonoid - Mirror #4 


Or if you preffer the BETA version of Microsoft Visual Studio 2011, then download it from:

Visual Studio 2011 BETA - x86


For Visual Basic 6 , you convert the code for MVS2011/10/08 or use this IDE:
Visual Basic 6.0 - Portable
Mirror
Visual Basic 6.0 - Portable + Libs

If you need Microsoft Visual Studio 2008, then use theese links:
Microsoft Visual Studio 2008 Express Edition - Portable
Mirror
Microsoft Visual Studio 2008 Professional
If any of the links are not working, please tell me ^^

Good luck!

[SNP] Show / Hide Folder Options in Windows Explorer [VB.NET]

 Shell("REG add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v NoFolderOptions /t REG_DWORD /d 1 /f", vbNormalFocus) 

A simple command, that uses registry, to enable or disable Folder Options in Windows Explorer.

Change the 1 to 0 to enable it again.

02 March, 2012

[SNP] Show / Hide Taskbar - Windows XP / 7 [VB.NET]

 Dim intReturn As Integer = FindWindow("Shell_traywnd", "")  
     SetWindowPos(intReturn, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)  
This will disable the taskbar.
And to enable it:
change SWP_HIDEWINDOW to SWP_SHOWWINDOW

MsgBox("Hello World!") - The Big Start

Hello there!

This is a blog about the great programming language Visual Basic.
Here you will find a variety of sources, tutorials, snippets and such.
I hope that it will be helpful to you!

P.S. Theese are written by me, or collected by me from the internet.All credits will be give, if found.
P.S.S. If you have questions, feel free to email me or comment.




And some words now:
vb.net visual basic programming visualstudio studio microsoft sources source codes code snippet snippets tutorial guide tutorials guides training free download snp src srcs snpt framework vb net .net VB.NET VisualBasic blog gratis gratuit gratis libre skid skidding programing vstudio SRC SNP project Projects