Friday, June 25, 2010

How to login into Youtube, Gmail, Yahoo, Facebook, Hotmail using Visual Basic 2010 or 2008 {VB.net}

Requirements:
4 Textbox (Textbox1, Textbox2, Textbox3, Textbox4)
1 Button (Name: Button1, Text: Set Cursor Position and Log me In"
2 Timers (Timer1 (Interval: 100, Enabled: True), Timer2 (Interval: 10000, Enabled: False)
2 Labels (Name: Label1 (Text: X), Label2 (Text: Y))


Codes:

Public Class Form1
Public Declare Sub SetCursorPos Lib "user32" (ByVal X As Integer, ByVal Y As Integer)
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN = &H8
Public Const MOUSEEVENTF_RIGHTUP = &H10

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
TextBox1.Text = Cursor.Position.X
TextBox2.Text = Cursor.Position.Y
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim first As Integer = TextBox3.Text
Dim second As Integer = TextBox4.Text
SetCursorPos(first, second)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
Timer2.Enabled = True
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
SendKeys.Send("YOUR YOUTUBE USERNAME")
SendKeys.Send("{TAB}")
SendKeys.Send("YOUR YOUTUBE PASSWORD")
SendKeys.Send("{ENTER}")
Timer2.Enabled = False
End Sub
End Class
_________________________________________________________________________

Here is the video tutorial:



Monday, June 14, 2010

Visual Basic - Screen Capturing Program Tutorial - Take a ScreenShot of your screen..! - VB.net

Requirements:
2 Buttons (Name: Button1 (Text: Capture), Button2 (Text: Save)

1 PictureBox (Size Mode: Stretched Image)

1 Timer (Name: Timer1) (Interval approx. 10000)


Codes:

Public Class Form1
'Button 2 = Capture
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Opacity = 0
Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim bounds As Rectangle
Dim screenshot As System.Drawing.Bitmap
Dim graph As Graphics
bounds = Screen.PrimaryScreen.Bounds
screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graph = Graphics.FromImage(screenshot)
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
PictureBox1.Image = screenshot
Timer1.Enabled = False
Me.Opacity = 100
End Sub

'Button1 = Save
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim savefiledialog1 As New SaveFileDialog
Try
savefiledialog1.Title = "Save File"
savefiledialog1.FileName = "Save As..."
savefiledialog1.Filter = "JPEG |*.jpeg"
If savefiledialog1.ShowDialog() = DialogResult.OK Then PictureBox1.Image.Save(savefiledialog1.FileName,System.Drawing.Imaging.ImageFormat.Bmp)
End If
Catch ex As Exception
'Do Nothing
End Try
End Sub

End Class
_________________________________________________________________________

Here is the video tutorial:





Wednesday, May 26, 2010

How to Create, Copy, Move, Rename, Delete File or Directory VB.net or Visual Basic

Hello and welcome to another cool vb.net tutorial. Today in this tutorial i will be teaching u all how to use the Directory or File Operations in Vb.net or Visual Basic



Requirements:
4 Timers (Name: Timer1, Timer2, Timer3, Timer4) (Interval: 150, 1000, 1000, 1000)
1 Label (Name: Label1) (Text: Status.)
8 Buttons (Name: Button1, Button2, Button3,Button4, Button5, Button6, Button7, Button8)(Text: Create Directory, Move Directory, Delete Directory, Create File, Copy File, Delete File, Rename File)

Codes:

Imports System.IO
Public Class Form1

Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
Timer1.Enabled = True
Timer2.Enabled = True
Timer3.Enabled = True
Timer4.Enabled = True
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = "Status"
Timer1.Enabled = False
Timer2.Enabled = True
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Label1.Text = "Status."
Timer2.Enabled = False
Timer3.Enabled = True
End Sub

Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
Label1.Text = "Status.."
Timer3.Enabled = False
Timer4.Enabled = True
End Sub

Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
Label1.Text = "Status..."
Timer4.Enabled = False
Timer1.Enabled = True
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim path As String = "c:\test"
If Directory.Exists(path) Then
Directory.Delete(path)
Label1.Text = "Directory Deleted Successfully"
Else
Label1.Text = "Directory Not Found"
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
If Not Directory.Exists("c:\test") = True Then
Label1.Text = "Directory Does Not Exist..Program will now create a Directory..!"
Directory.CreateDirectory("c:\test\")
Label1.Text = "Directory Created Successfully"
Else
Label1.Text = "Directory Already Exist..!"
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
Dim destination As String = "c:\hello"
Dim path As String = "c:\test"
If Directory.Exists(destination) Then
Label1.Text = "Folder with same name already exist in the destination "
ElseIf Directory.Exists(path) Then
Directory.Move(path, destination)
Label1.Text = "Directory Moved Successfully"
Else
Label1.Text = "Directory Already Exist in the location specified"
End If
End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
Dim oldname As String = "c:\hello"
Dim newname As String = "c:\Subscribe"
If Directory.Exists(oldname) And Not Directory.Exists(newname) Then
Directory.Move(oldname, newname)
Label1.Text = "Renaming was Successfull"
Else
Label1.Text = "There is folder already with same name in the Directory"
End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
Dim filetocreate As String = "c:\test.txt"
If Not File.Exists(filetocreate) Then
File.Create(filetocreate)
Label1.Text = "File Created Successfully"
Else
Label1.Text = "File Already Exist"
End If
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
Dim path As String = "c:\test.txt"
Dim destination As String = "c:\Subscribe\test.txt"
If File.Exists(path) And Not File.Exists(destination) Then
File.Copy(path, destination)
Label1.Text = "File Copied Successfully"
Else
Label1.Text = "There is already a file called test.txt in the Destination Folder"
End If
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
Dim filetodelete As String = "c:\test.txt"
If File.Exists(filetodelete) Then
File.Delete(filetodelete)
Label1.Text = "File Deleted Successfully"
Else
Label1.Text = "File Not Found"
End If
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
Dim oldname As String = "c:\Subscribe\test.txt"
Dim newname As String = "c:\Subscribe\Subscribe Please.txt"
If File.Exists(oldname) And Not File.Exists(newname) Then
File.Move(oldname, newname)
Label1.Text = "Renaming Was Successfull"
Else
Label1.Text = "File Already Exist with the same name"
End If
End Sub

End Class


Here is the video tutorial:



Sunday, May 23, 2010

Timespan Tutorial - Calculate the Date and Time Difference Between 2 Dates or Times Visual Basic {VB.net}

Hello and welcome to another cool VB.net tutorial by MrVBDude.!!!

Alright today i will be teaching u all how to calculate the time or date difference between two dates of two times.. ok so lets begin..!

REQUIREMENTS:
8 Labels (Name: Label1-Label8) (Text: StartDate, End Date, Start Time, End Time, Total Number of Days, Total Number of Hours, Total Number of Minutes, Total Number of Seconds)
2 DateTimePicker (Name: DateTimePicker1, DateTimePicker2)
8 Textbox (Name: Textbox1-Textbox8) (Text: " ")
1 Button (Name: Button1) (Text: Find Timespan (Time Difference) between 2 dates?)

Codes:

Public Class Form1

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

Dim date1 As Date
Dim date2 As Date
Dim difference As TimeSpan
date1 = Convert.ToDateTime(DateTimePicker1.Value)
date2 = Convert.ToDateTime(DateTimePicker2.Value)
difference = date2.Subtract(date1)
TextBox3.Text = FormatNumber(difference.Days, 0)
TextBox6.Text = FormatNumber(difference.TotalHours, 0)
TextBox5.Text = FormatNumber(difference.TotalMinutes, 0)
TextBox4.Text = FormatNumber(difference.TotalSeconds, 0)

End Sub

End Class
_________________________________________________________________________

Here is the video tutorial:

Sunday, May 16, 2010

ProgressBar Visual Basic {VB.net} Detailed Tutorial

Hello and welcome to another tutorial on vb.net. Today in this tutorial i will be teaching u all how to use the progressbar component in visual basic 2005, 2008, 2010.

Requirements:
2 ProgressBar - ProgressBar1, ProgressBar2
1 Label - Label1
4 Buttons (|<<,<<,>>,>>|)

Codes:

Public Class Form1

Dim myprogress As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ProgressBar1.Style = ProgressBarStyle.Marquee
ProgressBar2.Style = ProgressBarStyle.Continuous
ProgressBar2.Step = 1
Timer1.Enabled = True
ProgressBar1.Minimum = 0
ProgressBar1.Maximum = 100
ProgressBar1.Value = 0
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If ProgressBar1.Value <>
ProgressBar1.Value += 5
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If ProgressBar1.Value > 0 Then
ProgressBar1.Value -= 5
End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
ProgressBar1.Value = 100
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ProgressBar1.Value = 0
End Sub

Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
If e.Delta > -1 Then
If ProgressBar1.Value <>
ProgressBar1.Value += 5
End If
Else
If ProgressBar1.Value > 0 Then
ProgressBar1.Value -= 5
End If
End If
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ProgressBar2.Value = myprogress
If myprogress < myprogress =" myprogress">
Label1.Text = "Installing = " & myprogress & "%"
If myprogress = 100 Then
Label1.Text = "Complete"
ProgressBar1.Style = ProgressBarStyle.Continuous
ProgressBar1.Value = 0
Timer1.Enabled = False
End If
End Sub
End Class
_________________________________________________________________________

Here is the video tutorial: