- Note Pad++ is a free Source code editor
- It is very useful to edit the source codes.
- It supports several Languages to Create and Edit Source Codes.
Thursday, 26 January 2017
Note Pad++ Free Editor Download:
Sunday, 22 January 2017
Open Files through VB.NET Windows Application
Open Files through VB.NET Windows Application:
Process.Start("explorer.exe", "C:\Details.xlsx")- Use the below code for Open the files through VB.NET Windows Application.
Sunday, 16 March 2014
Create a Tool Tip for Windows Application using VB.Net
Create
Tool Tip using VB.NET:
- You Can Use the below code to create Tool Tip for Windows Application.
Dim toolTip1 As New ToolTip()
toolTip1.SetToolTip(Button6, "Add Details")
Create a Web Page for show current date and Time using VB.Net
Create a Web Page for show the Current Date and Time:
- Design Web Page Using Text Box, Label Box, and Button.
- Use Script manager, and Timer.
- Use the below code to show current date and time in vb.net web application.
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As
Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = Format(DateTime.Now, "dd/MM/yyyy")
TextBox2.Text = Format(Now, "Long
Time")
End Sub
Protected Sub Page_Load(ByVal sender As Object,
ByVal e As System.EventArgs) Handles Me.Load
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub
Protected Sub Timer1_Tick(ByVal sender As Object,
ByVal e As System.EventArgs) Handles Timer1.Tick
Label5.Text = Format(DateTime.Now, "dd/MM/yyyy")
Label4.Text = Format(Now, "Long
Time")
End Sub
End Class
Program for Student Information DataBase and Perform the Add, Delete, and Update
PROGRAM FOR STUDENT INFORMATION DATABASE AND PERFORM THE FOLLOWING
OPERATIONS: ADDITION, DELETION, AND UPDATION:
USING
ORACLE DATABASE:
FORM1:
Imports System.Data
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Public Class Form1
Private Sub Button4_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Form2.Show()
End Sub
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("PLEASE TYPE
NAME")
ElseIf TextBox2.Text = ""
Then
MsgBox("PLEASE TYPE DATE OF
BIRTH")
ElseIf TextBox3.Text = ""
Then
MsgBox("PLEASE TYPE ROLL
NO")
ElseIf TextBox4.Text = ""
Then
MsgBox("PLEASE TYPE
REGNO")
ElseIf TextBox5.Text = ""
Then
MsgBox("PLEASE TYPE
CLASS")
ElseIf TextBox6.Text = ""
Then
MsgBox("PLEASE TYPE
PERCENTAGE")
Else
Dim oradb As String = "Data
Source=XE;User Id=HR;Password=password;"
Dim conn As New
OracleConnection(oradb)
conn.Open()
Dim cmd As New OracleCommand
cmd.Connection = conn
cmd.CommandText = "insert into
SDB values ('" & TextBox1.Text & "','" & TextBox2.Text
& "','" & TextBox3.Text & "','" &
TextBox4.Text & "','" & TextBox5.Text & "','"
& TextBox6.Text & "')"
cmd.CommandType = CommandType.Text
cmd.ExecuteNonQuery()
MsgBox("Record is successfully
stored")
conn.Dispose()
End If
End Sub
Private Sub Button2_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form3.Show()
End Sub
Private Sub Button3_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Form4.Show()
End Sub
End Class
FORM 3:
Imports System.Data
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Public Class Form3
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("PLEASE TYPE REGISTER
NUMBER")
Else
Dim oradb As String = "Data
Source=XE;User Id=HR;Password=password;"
Dim conn As New OracleConnection(oradb)
conn.Open()
Dim cmd As New OracleCommand
Dim cmd1 As New OracleCommand
cmd.Connection = conn
cmd.CommandText = "SELECT *
FROM SDB WHERE REGNO='" & TextBox1.Text & "'"
cmd.CommandType = CommandType.Text
Dim dr As OracleDataReader
dr = cmd.ExecuteReader()
If dr.Read() Then
TextBox1.Text =
dr("REGNO")
cmd1.Connection = conn
cmd1.CommandText = "delete
from SDB WHERE REGNO='" & TextBox1.Text & "'"
cmd1.CommandType =
CommandType.Text
cmd1.ExecuteNonQuery()
MsgBox("Record is
successfully deleted")
conn.Dispose()
Else
MsgBox("REGISTER NUMBER IS
NOT AVOILABLE")
End If
End If
End Sub
End Class
FORM 4:
Imports System.Data
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Public Class Form4
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("PLEASE TYPE REGISTER
NUMBER")
Else
Panel1.Visible = True
End If
End Sub
Private Sub Form4_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Panel1.Visible = False
End Sub
Private Sub Button2_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox2.Text = "" Then
MsgBox("PLEASE TYPE
NAME")
ElseIf TextBox3.Text = ""
Then
MsgBox("PLEASE TYPE DOB")
ElseIf TextBox4.Text = ""
Then
MsgBox("PLEASE TYPE ROLL
NO")
ElseIf TextBox5.Text = ""
Then
MsgBox("PLEASE TYPE REG
NO")
ElseIf TextBox6.Text = ""
Then
MsgBox("PLEASE TYPE
CLASS")
ElseIf TextBox7.Text = ""
Then
MsgBox("PLEASE TYPE
PERCENTAGE")
Else
Dim oradb As String = "Data
Source=XE;User Id=HR;Password=password;"
Dim conn As New
OracleConnection(oradb)
conn.Open()
Dim cmd As New OracleCommand
cmd.Connection = conn
cmd.CommandText = "UPDATE SDB
SET NAME='" & TextBox2.Text & "',DOB='" &
TextBox3.Text & "',ROLLNO='" & TextBox4.Text &
"',REGNO='" & TextBox5.Text & "',CLASS='" &
TextBox6.Text & "',PERCENTAGE='" & TextBox7.Text &
"' WHERE REGNO='" & TextBox1.Text & "'"
cmd.CommandType =
CommandType.Text
cmd.ExecuteNonQuery()
MsgBox("Record is Successfully
Edited")
conn.Dispose()
End If
End Sub
End Class
USING MS SQL
DATABASE:
FORM 1:
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Private Sub Button4_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Form2.Show()
End Sub
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("PLEASE TYPE
NAME")
ElseIf TextBox2.Text = ""
Then
MsgBox("PLEASE TYPE DATE OF
BIRTH")
ElseIf TextBox3.Text = ""
Then
MsgBox("PLEASE TYPE ROLL
NO")
ElseIf TextBox4.Text = ""
Then
MsgBox("PLEASE TYPE
REGNO")
ElseIf TextBox5.Text = ""
Then
MsgBox("PLEASE TYPE
CLASS")
ElseIf TextBox6.Text = ""
Then
MsgBox("PLEASE TYPE
PERCENTAGE")
Else
Dim sqldb As String = "Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SDB.mdf;Integrated
Security=True;Connect Timeout=30;User Instance=True"
Dim con As New SqlConnection(sqldb)
con.Open()
Dim cmd As New SqlCommand
cmd.Connection = con
cmd.CommandText = "insert into
Table1 values ('" & TextBox1.Text & "','" &
TextBox2.Text & "','" & TextBox3.Text & "','"
& TextBox4.Text & "','" & TextBox5.Text &
"','" & TextBox6.Text & "')"
cmd.CommandType = CommandType.Text
cmd.ExecuteNonQuery()
MsgBox("Record is successfully
stored")
con.Dispose()
End If
End Sub
Private Sub Button2_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form3.Show()
End Sub
Private Sub Button3_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Form4.Show()
End Sub
End Class
FORM 3:
Imports System.Data
Imports System.Data.SqlClient
Public Class Form3
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("PLEASE TYPE REGISTER
NUMBER")
Else
Dim sqldb As String = "Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SDB.mdf;Integrated
Security=True;Connect Timeout=30;User Instance=True"
Dim conn As New
SqlConnection(sqldb)
conn.Open()
Dim cmd1 As New SqlCommand
cmd1.Connection = conn
cmd1.CommandText = "delete
from Table1 WHERE REGNO='" & TextBox1.Text & "'"
cmd1.CommandType = CommandType.Text
cmd1.ExecuteNonQuery()
MsgBox("Record is successfully
deleted")
conn.Dispose()
End If
End Sub
End Class
FORM 4:
Imports System.Data
Imports System.Data.SqlClient
Public Class Form4
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("PLEASE TYPE REGISTER
NUMBER")
Else
Panel1.Visible = True
End If
End Sub
Private Sub Form4_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Panel1.Visible = False
End Sub
Private Sub Button2_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox2.Text = "" Then
MsgBox("PLEASE TYPE
NAME")
ElseIf TextBox3.Text = "" Then
MsgBox("PLEASE TYPE DOB")
ElseIf TextBox4.Text = ""
Then
MsgBox("PLEASE TYPE ROLL
NO")
ElseIf TextBox5.Text = ""
Then
MsgBox("PLEASE TYPE REG
NO")
ElseIf TextBox6.Text = ""
Then
MsgBox("PLEASE TYPE
CLASS")
ElseIf TextBox7.Text = ""
Then
MsgBox("PLEASE TYPE
PERCENTAGE")
Else
Dim sqldb As String = "Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SDB.mdf;Integrated
Security=True;Connect Timeout=30;User Instance=True"
Dim conn As New
SqlConnection(sqldb)
conn.Open()
Dim cmd As New SqlCommand
cmd.Connection = conn
cmd.CommandText = "UPDATE
Table1 SET NAME='" & TextBox2.Text & "',DOB='" &
TextBox3.Text & "',ROLLNO='" & TextBox4.Text &
"',REGNO='" & TextBox5.Text & "',CLASS='" &
TextBox6.Text & "',PERCENTAGE='" & TextBox7.Text &
"' WHERE REGNO='" & TextBox1.Text & "'"
cmd.CommandType = CommandType.Text
cmd.ExecuteNonQuery()
MsgBox("Record is Successfully
Edited")
conn.Dispose()
End If
End Sub
End Class
Program for File Menu with Menu Items New, Open, Save, Print and Exit & Edit Menu with Menu Items Cut, Copy, Paste, Find and Undo
PROGRAM
FOR FILE MENU WITH MENU ITEMS NEW, OPEN, SAVE, PRINT AND EXIT & EDIT MENU
WITH MENU ITEMS CUT, COPY, PASTE, FIND AND UNDO:
Public Class Form1
Dim StringToPrint As String
Private Sub
SAVEToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles SAVEToolStripMenuItem.Click
Dim saveFileDialog1 As New
SaveFileDialog()
saveFileDialog1.Filter = "Text
File (*.txt)|*.txt |All Files |*.*"
saveFileDialog1.FileName =
"Untitled"
If saveFileDialog1.ShowDialog() =
DialogResult.OK Then
System.IO.File.WriteAllText(saveFileDialog1.FileName, RichTextBox1.Text)
MsgBox("FILE IS SAVED
SUCCESSFULLY")
End If
End Sub
Private Sub
FILEToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles FILEToolStripMenuItem.Click
End Sub
Private Sub
NEWToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles NEWToolStripMenuItem.Click
RichTextBox1.Text = ""
End Sub
Private Sub
OPENToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OPENToolStripMenuItem.Click
Dim OpenFileDialog1 As New
OpenFileDialog()
OpenFileDialog1.Filter = "Text
File (*.txt)|*.txt |All Files |*.*"
If OpenFileDialog1.ShowDialog() =
DialogResult.OK Then
RichTextBox1.Text =
System.IO.File.ReadAllText(OpenFileDialog1.FileName)
End If
End Sub
Private Sub
EXITToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles EXITToolStripMenuItem.Click
End
End Sub
Private Sub
PRINTToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PRINTToolStripMenuItem.Click
StringToPrint = RichTextBox1.Text
PrintDocument1.Print()
End Sub
Private Sub
CUTToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CUTToolStripMenuItem.Click
If RichTextBox1.SelectedText <>
"" Then
Clipboard.SetText(RichTextBox1.SelectedText)
RichTextBox1.SelectedText =
""
Else
MsgBox("No text is selected to
Cut")
End If
End Sub
Private Sub
COPYToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles COPYToolStripMenuItem.Click
If RichTextBox1.SelectedText <>
"" Then
Clipboard.SetText(RichTextBox1.SelectedText)
Else
MsgBox("No text is selected
to copy")
End If
End Sub
Private Sub
PASTEToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PASTEToolStripMenuItem.Click
Dim iData As IDataObject =
Clipboard.GetDataObject()
If
iData.GetDataPresent(DataFormats.Text) Then
RichTextBox1.SelectedText =
CType(iData.GetData(DataFormats.Text), String)
Else
MsgBox("Data in the clipboard
is not availble for entry into a textbox")
End If
End Sub
Private Sub
UNDOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles UNDOToolStripMenuItem.Click
RichTextBox1.Undo()
End Sub
Private Sub
REDOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles REDOToolStripMenuItem.Click
RichTextBox1.Redo()
End Sub
Private Sub
FINDToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles FINDToolStripMenuItem.Click
Dim a As String
Dim b As String
a = InputBox("Enter text to be
found")
b = InStr(RichTextBox1.Text, a)
If b Then
RichTextBox1.Focus()
RichTextBox1.SelectionStart = b - 1
RichTextBox1.SelectionLength =
Len(a)
Else
MsgBox("TEXT NOT FOUND")
End If
End Sub
Private Sub PrintDocument1_PrintPage(ByVal
sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Handles PrintDocument1.PrintPage
Dim numChars As Integer
Dim numLines As Integer
Dim stringForPage As String
Dim strFormat As New StringFormat()
Dim PrintFont As Font
PrintFont = RichTextBox1.Font
Dim rectDraw As New
RectangleF(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Width,
e.MarginBounds.Height)
Dim sizeMeasure As New
SizeF(e.MarginBounds.Width, e.MarginBounds.Height - PrintFont.GetHeight(e.Graphics))
strFormat.Trimming =
StringTrimming.Word
e.Graphics.MeasureString(StringToPrint,
PrintFont, sizeMeasure, strFormat, numChars, numLines)
stringForPage =
StringToPrint.Substring(0, numChars)
e.Graphics.DrawString(stringForPage,
PrintFont, Brushes.Black, rectDraw, strFormat)
If numChars < StringToPrint.Length
Then
StringToPrint =
StringToPrint.Substring(numChars)
e.HasMorePages = True
Else
e.HasMorePages = False
End If
End Sub
End Class
Subscribe to:
Posts (Atom)