FREE VB.NET SOURCE CODE

Showing posts with label visualbasic. Show all posts
Showing posts with label visualbasic. Show all posts

24 April, 2012

[SRC][SNP] FUD CodeDom Compiler ( RunPe ) [VB.NET]

This is a FUD ( for now ) RunPE / CodeDom Compiler, that was made by ByteBlast.
First, make a project with Form1 and add:
1 TextBox
1 Button

Code for Form1:

'Title: Self documentated CodeDom Builder || Author: ByteBlast || ►► ★ Coders | Offical .NET Help Desk ★◄◄
Imports System.Text
Imports System.CodeDom.Compiler

Public Class MainForm

    ''' 
    ''' Compilation [compiling] is the process of 'converting' a high level language such as VB.NET into 0's and 1's (low level language).
    ''' This method uses a series of classes and their methods available in the CodeDom.Compiler Namespace.
    ''' 
    ''' Path to write the executable.     ''' Syntax / Source code is just a string of text. You need to specify the code you wish to compile.     ''' 
    Private Sub Compile(ByVal ExecutableName As String, ByVal SourceCode As String)

        'The CreateProvider method returns a CodeDomProvider instance for the specificed language name.
        'This instance is later used when we have finished specifying the parmameter values.
        Dim Compiler As CodeDomProvider = CodeDomProvider.CreateProvider("VisualBasic")

        'Optionally, this could be called Parameters. 
        'Think of parameters as settings or specific values passed to a method (later passsed to CompileAssemblyFromSource method).
        Dim Settings As New CompilerParameters

        'The CompileAssemblyFromSource method returns a CompilerResult that will be stored in this variable.
        Dim Result As CompilerResults = Nothing

        '- Experiment with more properties in the CompileParameter class by typing "Settings." and exploring IntelliSense.

        'Generates an executable instead of a class library.
        Settings.GenerateExecutable = True

        'Set the assembly file name / path
        Settings.OutputAssembly = ExecutableName

        'Set assemblies referenced by the source code.
        Settings.ReferencedAssemblies.Add("System.dll")

        '/target:library, /target:win, /target:winexe
        Settings.CompilerOptions = " /target:winexe"

        'Determine if you want to treat all warnings as errors (ever noticed the green underscore in the Visual Studio? That indicates a warning).
        Settings.TreatWarningsAsErrors = False

        'Read the documentation for the result again variable.
        'Calls the CompileAssemblyFromSource that will compile the specified source code using the parameters specified in the settings variable.
        Result = Compiler.CompileAssemblyFromSource(Settings, SourceCode)

        'Determines if we have any errors when compiling if so loops through all of the CompileErrors in the Reults variable and displays their ErrorText property.
        If (Result.Errors.Count <> 0) Then
            MessageBox.Show("Exception Occured!", "Whops!", MessageBoxButtons.OK, MessageBoxIcon.Information)
            For Each E As CompilerError In Result.Errors
                MessageBox.Show(E.ErrorText)
            Next
        End If

    End Sub

    Private Sub BuildButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Source code is located in Resources.
        'Obtain the source and replace WEBSITE_URL with the specified URL by the user. [Process.Start("[WEBSITE_URL]")].
        Dim Source As String = My.Resources.Source.Replace("[WEBSITE_URL]", TextBox1.Text)

        'Displays a SaveFileDialogue, determines if the user clicked ok [error trap] and calls the user defined compile method.
        Dim S As New SaveFileDialog
        With S
            .Filter = "Executable (*.exe)|*.exe"
            If (.ShowDialog() = DialogResult.OK) Then
                Compile(.FileName, Source)
            End If
        End With
    End Sub
    Private Function ConvertBytesToString(ByVal bytes As Byte()) As String
        Return ASCIIEncoding.ASCII.GetString(bytes)
    End Function
    Private Function ConvertStringToBytes(ByVal str As String) As Byte()
        Return ASCIIEncoding.ASCII.GetBytes(str)
    End Function
   
End Class

Then add to resources "Source.txt", that contains:

Imports System.Diagnostics

Module Module1

    Sub Main()
        Process.Start("[WEBSITE_URL]")
    End Sub

End Module

[SNP] Convert Bytes array to String and String to Bytes array [VB.NET]

Firstly:

Imports System.Text

And then add the functions:

   Private Function ConvertBytesToString(ByVal bytes As Byte()) As String
        Return ASCIIEncoding.ASCII.GetString(bytes)
    End Function
    Private Function ConvertStringToBytes(ByVal str As String) As Byte()
        Return ASCIIEncoding.ASCII.GetBytes(str)
    End Function

You can use it as this:

      'This is how you convert string to bytes array
        Dim Data() As Byte = ConvertStringToBytes("String to be converted")
        'And this is the reverse one
        Dim STR As String = ConvertBytesToString(Data)
     

29 March, 2012

[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] 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 .

[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