Friday 25 January 2013

Using VB.net Turning a File to a Graphics

Using VB.net Turning a File to a Graphics

Example of a graphic.



The Demo. Download Here


VB.net .EXE in Memory

VB.net .EXE in Memory

First of all for this to work you will need to make a Windows Form Application.

Example 1:















Then Disable Application Framework:

Example 2:

















' Now We can Create Sub Main.
' Create A new Module, Add the following Code.

Sub Main(Byval args() As String)
Dim X As New Form1
X.ShowDialog
End Sub

' On Example 2 Change the Start up object to Sub Main

' Now This is the .EXE you want to load in Memory...
' Build...
' Locate the .EXE and Rename to .TXT
' Make a New Project.
' On Example 2, Click on the Resource Tab on the Left.
'














' Add your .TXT File.
' Now we have the File.

' Double Click on the Form.
' Should See this.


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

' Then Type This Code.


Dim a As System.Reflection.Assembly = System.Reflection.Assembly.Load(Encoding.Default.GetBytes(My.Resources.#YourExeFileName#)))
' search for the Entry Point
Dim method As MethodInfo = a.EntryPoint
If method IsNot Nothing Then
Dim o As Object = a.CreateInstance(method.Name)
Dim args() As String = Nothing
method.Invoke(o, New Object() {args})
End If
Me.Close()

' Then Run



Wednesday 23 January 2013

VB.Net Basic Reading And Writing

VB.Net Basic Reading And Writing

Imports System.IO

' Drag and Drop OpenFileDialog1 onto your form.

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

OpenFileDialog1.ShowDialog

End Sub

' Go to Designer and click the OpenFileDialog1 on the bottom.
' Go to the settings on the right.
' you will see a lightning bolt.

End Class


















' Click on the lightning bolt.
' Double Click on 'FileOk'

 you will see a code snippet like this.
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk

' Type this,
If File.Exist(OpenFileDialog1.FileName) Then
Dim ByteArray() As Byte = File.ReadAllBytes(OpenFileDialog1.FileName)

' Now we have the file in Bytes. Best Way to open it.
' Lest Save this File in a Different Location.
File.WriteAllBytes(InputBox("File Name"), ByteArray)
Else
MsgBox("File Does Not Exit")
End If

End Sub

' Simple use File. to get Files.
' or Directory. to get Folders.

VB.Net GUI Graphic User Interface.

VB.Net GUI Graphic User Interface.

Getting The Basics Done.

Start from Clicking the Sidebar on the left "ToolBars" Find the SubMenu All Windows Forms.
Click "Button"
















Then Drag the button to the form.

Double Click on the Button, The Code Snippet That gets generated will handle the click even for that button.
now we want to type.

MsgBox("Login Event")

' This is a Dummy Event.
' Now Go Back to the Form Designer, By Clicking on View, then Click Designer.
' Now we want to add to Textbox's. Go through the ToolBar and Find "TextBox"
' Now Add Another Textbox Underneath your other Textbox.

Should Look Like This.


















' Go Back To your Code, By View, Code
Up the top of the Page you will see "Public Class Form1"
Underneath that line write this.

Friend Username As String = "Admin"
Friend Password As String = "Pass"

' These are your variables to login.
' Go Back to your Designer.

Double Click on your "Button."

Delete the Dummy Code "MsgBox("Login Event")"

Type this:

If Textbox1.Text = Username And Textbox2.Text = Password Then
MsgBox("Welcome" & Username)
Else
MsgBox("Invalid Password or Username")
End If

now you are done.

VB.Net Arrays & Booleans

VB.Net Arrays & Booleans

Getting Started with Arrays. Simple Arrays:

Dim TempStringArray() As String = Split("Name1,Name2,Name3", ",")

' Result, TempStringArray(0) = "Name1", TempStringArray(1) = "Name2", TempStringArray(2) = "Name3".

Arrays start at 0 so a array of (Arrays(3)) Length is 4...

Booleans are very helpful.

Boolean can have 3 responses (True, False, Nothting(Null) or VbNull)

you can have an Array of any Object Types... etc

Dim TempIntArray(9) As Integer

' Getting the Length of a Array, there are to ways, Ubound() = the Length - 1
' Or TempIntArray.Length = 10
' Example:

' Ubound(TempIntArray) = 9
' TempIntArray.Length = 10

etc...

For I As Long = 0 To Ubound(TempIntArray)
TempIntArray(i) = i
Next

Vb.net For Statements & Loops

For Statements:

The Basic For Statement Looks like this:

Dim i As Long = 0
Dim x As Long = 0

For i = 0 To 10
x +=2
Next

MsgBox(x.ToString)

While Statements

Dim i As Long = 0
Dim ExitMe As Boolean = False

While ExitMe = False
i +=1
If i = 10 Then
ExitMe = True
End If
End While

Do Until

Dim i As Long = 10
Do Until (i < 0)
i-=1
loop

Vb.net If Statements

VB.Net If Statements

Example:

Dim X As Boolean = False

If X = False Then
Stop
Else
Exit Sub
End If

Dim Y As Long = 0

If Y = 0 Then
Stop
End If

Dim Z As DataBase = Nothing

If Z Is Nothing Then ' Answer is True.
Stop
End If

Dim L As Integer = 2

If L = 1 Or L = 2 Then ' Answer is True. Because L is 2
Stop
End If

Dim P As Long = 1

If P <> 0 Then
' True
End if

Dim O As Long = 9

If O >= 9 Then
' True
End If

VB.net Basic Variable Types

VB.net Variable Types:

To get started the first Variable type you will use is a Type Call "String", a string contains display variables, for example. VB.Net Contains 6 Characters, another Type is "Char" a char is a single Display Value for a Byte of Data. Example "a" is a char, Another type is Byte, byte is a numeric value for a Display Value. There are 0 - 255 Ascii Characters and Bytes in a default Ascii Table. Another Type is Integer, a numeric Value -2.142 billion To 2.142 billion.

Example:

Dim TempString As String = cStr("TempString")
Dim TempChar As Char = cChar("c")
Dim TempByte As Byte = cByte(10)
Dim TempInteger As Integer = 10

VB.net Tutorial 1

Getting Started:

Please make sure you have Visual Studio, you can get visual studio from Here or Here. Now that we have Visual Studio we will begin by making a New project.

Step 1:
















Then select Windows Forms Application














Step 2

Now you will see a form.



















Step 3

Now here is the tricky bit, Double Click on the Grey Background of the form, you will then see a Code Snippet that handles the form_load.

Type the following code.

Dim Answer As String
Answer = "Hello World"
MsgBox(Answer)

Thats it, welcome to Vb.net