Saturday, April 13, 2013

How to detect an ENTER click in VB.NET!

This can be easily be used to detect an enter click in VB.NET! It only takes a couple lines of code. Here is how you can do it.


Protected Overrides Function ProcessDialogKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean
        Select Case (keyData)
            Case Keys.Enter
                ButtonX4.PerformClick()
                Return True

        End Select
        Return MyBase.ProcessDialogKey(keyData)
    End Function

This is a real value tutorial when you want to learn visual basic coding. Next Tutorial coming soon!

Friday, April 12, 2013

[VB.NET] How to save data to the registry.

Today I will show you how to sava data to your registry. I will show you the following things.

- Check if a registry key value exists.
- Create sub keys and add values to them.




 Checking if a registry key is set

If My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Drivers", "Hash", Nothing) Is Nothing Then
'Your Code Here
End If

Be sure to change the "HKEY_CURRENT_USER\Drivers" and "Hash" to whatever you want.

Creating a new sub key

To create a subkey all you have to do is this.

My.Computer.Registry.CurrentUser.CreateSubKey("Hash") 

Change the "Hash" to whatever you want

Adding a value to your new sub key

Dim Hash as String = "yourhashkeyvalue"
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Drivers", "Hash", Hash)

So this code will input the value of Hash ("yourhashkeyvalue") and input that into the has subkey.


If you are looking for a good registry cleaner then be sure to check out this site.


How to Create Variables in VB .NET


With Visual Basic, and most programming languages, what you are doing is storing things in the computer's memory, and manipulating this store. If you want to add two numbers together, you put the numbers into storage areas and "tell" Visual Basic to add them up. But you can't do this without variables.
So a variable is a storage area of the computer's memory. Think of it like this: a variable is an empty cardboard box. Now, imagine you have a very large room, and in this room you have a whole lot of empty cardboard boxes. Each empty cardboard box is a single variable. To add two numbers together, write the first number on a piece of paper and put the piece of paper into an empty box. Write the second number on a piece of paper and put this second piece of paper in a different cardboard box.
Now, out of all your thousands of empty cardboard boxes two of them contain pieces of paper with numbers on them. To help you remember which of the thousands of boxes hold your numbers, put a sticky label on each of the two boxes. Write "number1" on the first sticky label, and "number2" on the second label.
What have we just done? Well, we've created a large memory area (the room and the cardboard boxes), and we've set up two of the boxes to hold our numbers (two variables). We've also given each of these variables a name (the sticky labels) so that we can remember where they are.
Now examine this:
Dim number1 As Integer
Dim number2 As Integer
number1 = 3
number2 = 5

That's code from Visual Basic Net. It's VB's way of setting up (or declaring) variables.
Here's a breakdown of the variable Declaration:
Dim

Short for Dimension. It's a type of variable. You declare (or "tell" Visual Basic) that you are setting up a variable with this word. We'll meet other types of variables later, but for now just remember to start your variable declarations with Dim.

number1

This is the cardboard box and the sticky label all in one. This is a variable. In other words, our storage area. After the Dim word, Visual Basic is looking for the name of your variable. You can call your variable almost anything you like, but there are a few reserved words that VB won't allow. It's good practice to give your variables a name appropriate to what is going in the variable.


As Integer
We're telling Visual Basic that the variable is going to be a number (integer). Well meet alternatives to Integer later.

Number1 = 3


The equals sign is not actually an equals sign. The = sign means assign a value of. In other words, here is where you put something in your variable. We're telling Visual Basic to assign a value of 3 to the variable called number1. Think back to the piece of paper going into the cardboard box. Well, this is the programming equivalent of writing a value on a piece of paper
Now that you have a basic idea of what variables are, let's write a little piece of code to test them out. First, though, let's have our first look at the coding window.
To make life easier, we're going to put a button on our form. When our button is clicked, a little message box will pop up. Fortunately, there's no coding to write for a button, and very little at all for a message box.

Wednesday, April 10, 2013

[VB.NET] Integrating a proxy system into your application

This is a nice and simple tutorial on how to integrate a proxy system into your application. With these easy steps we will have you up and running with your own proxy integration, that will allow you to change your ip in your application. 

Step 1) Add a brand new module to your visual basic project as seen in the image below, name it Proxy.vb and click add




Step 2) Add this code to your proxy module. This is what your code should look like after you are done.


Module Proxy
    ' The structure we use for the information
    ' to be interpreted correctly by API.
    Public Structure Struct_INTERNET_PROXY_INFO
        Public dwAccessType As Integer
        Public proxy As IntPtr
        Public proxyBypass As IntPtr
    End Structure

    ' The Windows API function that allows us to manipulate
    ' IE settings programmatically.
    Private Declare Auto Function InternetSetOption Lib "wininet.dll" _
    (ByVal hInternet As IntPtr, ByVal dwOption As Integer, ByVal lpBuffer As IntPtr, _
     ByVal lpdwBufferLength As Integer) As Boolean

    ' The function we will be using to set the proxy settings.
    Public Sub RefreshIESettings(ByVal strProxy As String)
        Const INTERNET_OPTION_PROXY As Integer = 38
        Const INTERNET_OPEN_TYPE_PROXY As Integer = 3
        Dim struct_IPI As Struct_INTERNET_PROXY_INFO

        ' Filling in structure
        struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY
        struct_IPI.proxy = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(strProxy)
        struct_IPI.proxyBypass = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi("local")

        ' Allocating memory
        Dim intptrStruct As IntPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(struct_IPI))

        ' Converting structure to IntPtr
        System.Runtime.InteropServices.Marshal.StructureToPtr(struct_IPI, intptrStruct, True)
        Dim iReturn As Boolean = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(struct_IPI))
    End Sub
End Module

Step 3) To easily Change your proxy within your application ....all you need to do is this code.

Proxy.RefreshIESettings("proxy:ip") 'Make sure your ip looks like "111.111.1.1:80"






Hopefully this guide has belped you and if you need any help let me know.

A next tut might be how to spoof your browser and referrer and how to make it look like you are using different internet browsers.




How do I get going with Visual Studio Professional?

I get alot of people who wonder how they can start off coding with vb.net, and they have no idea what to even install their first time coding. You are going to want the following software :



Visual Studio Professional (2012) - http://www.microsoft.com/visualstudio/eng/downloads

This is the best software to help you learn visual studio and to become a master in vb.net or many languages on the web.

1) You are going to want to start off by installing the visual studio program from the link above. It is a very easy install process and it takes about 10-15 minutes to install.

2) Make sure when you first start off running the program you select a blank form as a vb project.

You can get a ton of visual studio training and guides online if you are not sure about what to do and hopefully this guide helped you a little bit.

Some Great Resources

Youtube Video to help with install:


Thanks for reading this quick guide and hopefully I helped you!

Cool Background for Visual Studio!

Cool Background image I found for Visual Studio.


Original Src here: http://www.cnmeonline.com/wp-content/uploads/2013/03/visualstudio-wallpaper-05.jpg

GetElementsByTagName VB.NET Tutorial

You can easily get code within tags by using this very simple code.


Dim PageElements3 As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input") 
            For Each CurElement As HtmlElement In PageElements3
                If CurElement.GetAttribute("id") = "strFirstName" Then
                    WebBrowser1.Document.GetElementById("strFirstName").Focus()
                    CurElement.InnerText = datastringbefore(0)
       End If
Next

Where input = the tag you want to search for
     and
Where id = the attribute of the tagname you are searching for

Hope you guys enjoyed this quick tutorial.