Thursday, 16 August 2012

functions in vb.net

In this tutorial, we cover the Function and how it works. Similar to the sub procedure, a function is also a method which stores code to be executed when called. The difference is a function returns a value where a sub procedure doesn’t. When merging more than one code block simply call function name and pass arguments. Copy and paste below Code:
Public Class Form1
Dim labeltext As String = "functions are cool lol"
Private Function changelabeltext()
Return labeltext
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = changelabeltext()
End Sub
End Class

Monday, 13 August 2012

Multithreading in vb.net

In this tutorial, we cover the concept of Multithreading. Multi Threading allows an application to run different bits of code at the same time without causing your User Interface to become unresponsive. This tutorial will hopefully explain the concept of multithreading to you and use of multithreading in advanced run one application more than one time and saving your time. Example if you want enter student data base at a time for different student data we can’t enter that’s why we come across multithreading, Make multithreading application 2 labels 2 buttons Explain Line:
1) Declare two variables and name it as (i) and (i2)
2) Declare two Threading variables as thread1 and thread2
3) Create two sub countup(),countup2()
4) And start thread by New System.Threading.Thread(AddressOf countup)
5) And start 2nd thread by New System.Threading.Thread(AddressOf countup)
6) Start threads Copy and paste below Code:
Public Class Form1
Dim i As Integer
Dim i2 As Integer
Dim thread As System.Threading.Thread
Dim thread2 As System.Threading.Thread
Private Sub countup()
Do Until i = 10000
i = i + 1
Label1.Text = i
Me.Refresh()
Loop
End Sub
Private Sub countup2()
Do Until i2 = 10000
i2 = i2 + 1
Label2.Text = i2
Me.Refresh()
Loop
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
thread = New System.Threading.Thread(AddressOf countup)
thread.Start()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
thread2 = New System.Threading.Thread(AddressOf countup2)
thread2.Start()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.CheckForIllegalCrossThreadCalls = False
End Sub
End Class

Sunday, 12 August 2012

log in using id in vb.net part 2



This tutorial is an extension of the previous tutorial which covered how to retrieve every HTML element in a web page. This tutorial will show you how to click a button that doesn’t have an ID.

Use this application is login facebook without using (open web browser) and modifies this application you can open facebook login in double clicking the application
·         As usual for navigating your application all you need web browser for that add web browser and for navigate enter address of login page and click go
·         Reading all html element and find element login then invoke the login element

Make this application all you nedd
1 we browser
1 Text box
1 button


Copy and paste below Code:

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.Navigate("http://login.facebook.com/login.php")
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim allelements As HtmlElementCollection = WebBrowser1.Document.All
        For Each webpageelement As HtmlElement In allelements
            If webpageelement.GetAttribute("value") = "Log In" Then
                webpageelement.InvokeMember("click")
 End If
 Next
 End Sub
End Class

get all html element in vb.net

In this tutorial, we cover how to interact with every single HTML Element in a web page. First navigate your page and as usual using built in web browser in application First line get all html element collection to get that we use web browser document all For each element we listed in list box and use for further To make this application all you need 1 web browser 1 Text box 1 List box 1 button Copy and paste below Code:
Public Class Form1
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 WebBrowser1.Navigate("www.youtube.com")
 End Sub
 Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
 Dim allelements As HtmlElementCollection = WebBrowser1.Document.All
 For Each webpageelement As HtmlElement In allelements
 ListBox1.Items.Add(webpageelement.GetAttribute("src"))
 Next
 End Sub 
End Class

log in page using vb.net part 1


n this tutorial, we cover how to log into a website by interacting with HTML elements in a page using the element ID. Don’t worry if you don’t quite understand it yet, there are a few more tutorials that will explain it in more depth. Interacting with HTML elements is a good way to create a bot that will automate web page tasks. Login a page is accessing (remotely accessing webpage or login ny user name and password)

Explain each line by line
      Give login page address in web browser navigation bar and click go
        Set your  attribute  like username (user) and password
      Click 2nd button to login remotely from your application
       Make text box to enter data and labels for good user interface

     In first line webbrowser1.navigate is your web browser in application if you don’t know how to add web browser see some (I added posts about webbroswer) article explain how to add web browser and that web browser is navigate to your login page and from there to login your page using application
     Get element by id is to get an class of and attribute and set value you given for login
     Same as the password attribute and save
Copy and paste below Code:

Public Class Form1



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        WebBrowser1.Navigate("http://login.yahoo.com/")

    End Sub



    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        WebBrowser1.Document.GetElementById("login").SetAttribute("value", TextBox1.Text)

        WebBrowser1.Document.GetElementById("passwd").SetAttribute("value", TextBox2.Text)



        WebBrowser1.Document.GetElementById(".save").InvokeMember("click")

    End Sub



End Class

HttpWebRequest and HttpWebResponse in vb.net

In this tutorial, we cover using the HttpWebRequest and HttpWebResponse. We use it to obtain the source code of a web page that I have created. We also use the Stream Reader to read the text and then place it into a textbox. In this application you get source code of html file in the textbox simple to use make complex in this application is under stand (the HttpWebRequest and HttpWebResponse). Copt and paste below Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(TextBox2.Text)
        Dim response As System.Net.HttpWebResponse = request.GetResponse()

        Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())

        Dim sourcecode As String = sr.ReadToEnd()

        TextBox1.Text = sourcecode
    End Sub

End Class

Auto Typer in vb.net

This tutorial will teach you how to make your very own Auto Typer. Auto Typers are popular across the web and in some cases people charge money for them. With this easy tutorial, you can create your own customizable Auto Typer and share it with your friends. We have covered Timers in a previous tutorial but this tutorial will cover how to Send Keys. Copy and paste below Code
Public Class Form1

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        SendKeys.Send(TextBox1.Text)
        SendKeys.Send("{Enter}")
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Interval = TextBox2.Text * 1000
        Timer1.Start()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Stop()
    End Sub

End Class

sending an email by connecting to an SMTP server using VB.NET

In the previous tutorial, we covered sending an email by connecting to an SMTP server using VB.NET. In this tutorial, we will create a Graphical User Interface for the user. As I mentioned in previous article making User Interface of your sending mail add 3 textboxes design as per you required and the extra things in this is adding user name, password, body of letter, from e-mail, to e-mail and subject etc. make good User Interface is better practice and good reputations you application Copy and paste below Code: Imports System.Net.Mail
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Mail As New MailMessage
        Mail.Subject = "test email"
        Mail.To.Add(TextBox2.Text)
        Mail.From = New MailAddress(TextBox2.Text)
        Mail.Body = TextBox1.Text

        Dim SMTP As New SmtpClient("smtp.gmail.com")
        SMTP.EnableSsl = True
        SMTP.Credentials = New System.Net.NetworkCredential(TextBox2.Text, TextBox3.Text)
        SMTP.Port = "587"
        SMTP.Send(Mail)
    End Sub

End Class

send an email using only code in vb.net

In this tutorial, we will learn how to send an email using only code. The example in this tutorial will show you how to send an email by connecting to the googlemail SMTP server. If you want to send an email using another service such as hotmail or yahoomail, you will need to google for the SMTP host and port for that particular service. Modify the code like this give text boxes for subject, add, from etc. First line of code is declare mail as mail message, next line is subject of sending mail, next line enter your mail, and to mail, and body of the mail. Next line is setup smtpclient of google and send mail Copy and paste below Code: Imports System.Net.Mail
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Mail As New MailMessage
        Mail.Subject = "test email"
        Mail.To.Add("youremail@googlemail.com")
        Mail.From = New MailAddress("youremail@googlemail.com")
        Mail.Body = "This is an ownage email using VB.NET"

        Dim SMTP As New SmtpClient("smtp.gmail.com")
        SMTP.EnableSsl = True
        SMTP.Credentials = New System.Net.NetworkCredential("username", "password")
        SMTP.Port = "587"
        SMTP.Send(Mail)
    End Sub

End Class

FTP server using Visual Basic .NET.

In this tutorial, we cover uploading files to an FTP server using Visual Basic .NET. Nowadays All are using ftp software to upload file their site, here a simple and easy code to upload file to your site using vb.net. You can modify code that file path to give open file dialog box and many more complex make your own ftp. It’s easy copy hard to understand. First line of code give a site path where to upload and give user name and password and next line upload file, get file from computer and upload to server. Before start import system.io Copy and paste below Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://ftp.drivehq.com/file.txt"), System.Net.FtpWebRequest)
        request.Credentials = New System.Net.NetworkCredential("user", "password")
        request.Method = System.Net.WebRequestMethods.Ftp.UploadFile

        Dim file() As Byte = System.IO.File.ReadAllBytes("c:\file.txt")

        Dim strz As System.IO.Stream = request.GetRequestStream()
        strz.Write(file, 0, file.Length)
        strz.Close()
        strz.Dispose()
    End Sub

End Class

Tuesday, 7 August 2012

listbox in vb.net

This tutorial will introduce the ListBox object and give you a basic understanding of how it works. There are more practical uses than the one shown in this application but as we are still in the early stages, this example is for beginners. In depth to tell about list box add item line by line, for example you’re adding text in textbox and want that text in list box use this tutorial you can add text from text box to list box Syntax: ListBox1.Items.Add(TextBox1.Text) This will copy the content in textbox.text to list box line by line Copy and paste below Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListBox1.Items.Add(TextBox1.Text)
    End Sub

End Class

my first application in vb.net

This tutorial will help you create your first application using Visual Basic .NET. In this tutorial, we write our first piece of code by telling the application to show a message box displaying the text “Hello World”.” Hello world” Is all common application in beginning of coding and its simple show message box in vb.net application just one line to show message box
Syntax: messagebox.show{“show what message ”}


Copy and paste below Code:

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MessageBox.Show("Hello World", "Message Box Title")
    End Sub

End Class

menu strip in vb.net

This tutorial will introduce the Menu Strip object for Visual Basic .NET applications.
 Having a Menu Strip will improve the usability of your application and allow you to expand it more.
 Every professional application has a Menu Strip; just take a look at your web browser!
Menu strip look same when you made complex work in it and its easy to use menu strip in vb.net applications.  

Copy and paste below Code:

Public Class Form1

    Private Sub HelpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HelpToolStripMenuItem.Click
        MessageBox.Show("this is the help form")
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close()
    End Sub

End Class