Tag Archives: vb.net

Login to Facebook using VB.net

January 9, 2012

2 Comments


Hello People

So after a long absence from bytebeats i am back in business . Here is my recent code that i have been working on from the last few days so thought of sharing it with you.

Currently this code is working for facebook but you can use this code for any website you want. If you want to login to facebook using vb.net then follow the following code.

Create a form application in vb.net

Drag a WebBrowser component to the form and paste the following code in the Class.

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate(“https://www.facebook.com/login.php”)
End Sub

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

WebBrowser1.Document.GetElementById(“email”).SetAttribute(“value”, “email@email.com”)
WebBrowser1.Document.GetElementById(“pass”).SetAttribute(“value”, “password”)
WebBrowser1.Document.GetElementById(“login”).InvokeMember(“click”)
End Sub

End Class

 

Description

WebBrowser1.Navigate(“https://www.facebook.com/login.php”)

This line will navigate to the home page of facebook.

Then the event DocumentComplete will be fired and the following code will fill the username and password in the input fields. You can write all the code in the Load method but it will crash after the navigate because you have to wait for the document to load in the WebBrowser component.

WebBrowser1.Document.GetElementById(“email”).SetAttribute(“value”, “email@email.com”)
WebBrowser1.Document.GetElementById(“pass”).SetAttribute(“value”, “password”)

This code will click the log in to log in to facebook.

WebBrowser1.Document.GetElementById(“login”).InvokeMember(“click”)

 

Happy coding

 

 

var _gaq = _gaq || [];
_gaq.push([‘_setAccount’, ‘UA-29654614-1’]);
_gaq.push([‘_trackPageview’]);

(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();

Continue reading...

Deploy a VB.net Application . .

September 30, 2011

0 Comments


So if you have created an application and you want to make a setup file that can create icon and a button in in your start menu then follow the following procedure

http://msdn.microsoft.com/en-us/library/31kztyey(v=VS.90).aspx

Copied from MSDN

  1. In Solution Explorer, right-click the application project and click Properties.The Project Designer appears.
  2. Click the Publish tab to open the Publish page in the Project Designer, and click the Publish Wizard button.The Publish Wizard appears.
  3. In the Where do you want to publish the application? page, enter the file path or FTP location where the application will be published, for example d:\deploy. Then click Next to continue.
  4. On the How will users install the application? page, click From a CD-ROM or DVD-ROM, and then click Next.

  5. If you distribute your application on CD-ROM, you might want to provide updates from a Web site. In the Where will the application check for updates? page, choose an update option:
    • If the application will check for updates, click The application will check for updates from the following location and enter the location where updates will be posted. This can be a file location, Web site, or FTP server.
    • If the application will not check for updates, click The application will not check for updates.

    Click Next to continue.

  6. Click Finish to publish the application.
Continue reading...

Using TreeView in VB.NET

September 29, 2011

6 Comments


Hey

The following code is using a TreeView to show the directories in  given directory. If you click on any of the directory you will also be able to see the files in  the directory in a ListBox.

Create a new window form project and just add a TextBox, A treeview object and a listBox on the form and paste the following code in Form1.vb.

******************************************************************************************************

 

Public Class Form1

   Private Sub Form1_Load(ByVal sender As System.Object, _
                          ByVal e As System.EventArgs) _
                  Handles MyBase.Load
      TextBox1.Text = "C:\ascade"
      If Not String.IsNullOrEmpty(TextBox1.Text) Then
         'clearing the previous data
         ListBox1.Items.Clear()
         Dim fNode As New TreeNode
         fNode.Text = "Main"
         fNode.Name = TextBox1.Text
         fNode.Nodes.Add("")
         TreeView1.Nodes.Add(fNode)
         PoulateTree(fNode)
         TreeView1.ExpandAll()
      End If

   End Sub

   Public Sub PoulateTree(ByRef parentNode As TreeNode)
      If parentNode.Nodes(0).Text = "" Then
         parentNode.Nodes(0).Remove()
         'get all the directories
         Dim DirInfo As New IO.DirectoryInfo(parentNode.Name)
         For Each d As IO.DirectoryInfo In DirInfo.GetDirectories
            Dim ChildNode As New TreeNode
            ChildNode.Text = d.Name
            ChildNode.Name = d.FullName
            If d.GetDirectories.Count > 0 Then
               ChildNode.Nodes.Add("")
               parentNode.Nodes.Add(ChildNode)
               PoulateTree(ChildNode)
            Else
               parentNode.Nodes.Add(ChildNode)
            End If

         Next
      End If
   End Sub

   Private Sub TreeView1_AfterSelect(ByVal sender As Object, _
                  ByVal e As System.Windows.Forms.TreeViewEventArgs) _
                                     Handles TreeView1.AfterSelect
      ListBox1.Items.Clear()
      Dim DirInfo As New IO.DirectoryInfo(e.Node.Name)
      For Each f As IO.FileInfo In DirInfo.GetFiles
         ListBox1.Items.Add(f.Name)
      Next
   End Sub
End Class

******************************************************************************************************

If you need the full code leave a comment with your email address and i will send you the full code.

 

 

Continue reading...

How to get appointments from a power point Pst file using VB.NET

July 21, 2011

2 Comments


This method will get the appointments from a power point calender.

Public Function getAppointment(ByVal file As String) As List(Of String)
    Dim AppointmentDetails As New List(Of String)
    Dim App As New List(Of ItemCollection)
    Dim calendar As Folder
    Dim PSTfile = New PstFile(file)
    Dim delta As TimeSpan = MonthCalendar1.SelectionEnd - MonthCalendar1.SelectionStart
    Dim DelResult As Integer = delta.Duration.Days
    Using PSTfile
        calendar = PSTfile.MailboxRoot.GetFolder("calendar")
        If calendar IsNot Nothing Then
            Dim items As ItemCollection = calendar.GetItems()
            For m As Integer = 0 To items.Count - 1

                If TypeOf items(m) Is Appointment Then
                    Dim appointment As Appointment = DirectCast(items(m), Appointment)
                    AppointmentDetails.Add(appointment.Subject)
                    AppointmentDetails.Add(appointment.CreationTime)
                    AppointmentDetails.Add(appointment.CreationTime.Date)
                    AppointmentDetails.Add(appointment.Duration)
                End If
            Next
        End If
    End Using
    Return AppointmentDetails
End Function

Full article

http://stackoverflow.com/questions/6743299/extract-appointments-from-pst-file-without-loop

 

Continue reading...