Phone Book Application Program In Visual Basic 2008/2010/.NET - VB Tutorials - Basics Projects
http://ingenuitydias.blogspot.com/2014/04/phone-book-application-program-in.html
For Phone Book Application Program you need 2 Forms
Form1: Will be used to search contacts.
Form2: Will be used to add new contacts.
Form1: Add a textbox, a list-box, a label and 2 buttons:
More Visual basic Codes:
Creating Your First project in Visual Basic 2008/2010/.NET
Creating a Log In Application Program In Visual Basic 2008
Analog Clock In Visual Basic 2008/2010/.NET
Double click on textbox1 and the following code:
Click on Project menu, then click on the last menu, (in this project: Simple Phone Book Properties)
Then click on Settings tab.
Add Names under Name Column, and System.Collections.Specialized.StringCollection under Type:
Add the following code to Form1.Load event:
Form2: Add 2 textboxes, 2 labels and 2 buttons:
Cancel Button Code:
Form1: Will be used to search contacts.
Form2: Will be used to add new contacts.
Form1: Add a textbox, a list-box, a label and 2 buttons:
More Visual basic Codes:
Creating Your First project in Visual Basic 2008/2010/.NET
Creating a Log In Application Program In Visual Basic 2008
Analog Clock In Visual Basic 2008/2010/.NET
Double click on textbox1 and the following code:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesTextBox1.TextChanged
Dim item As String = TextBox1.Text.ToString()
Dim index As Integer = ListBox1.FindString(item)
If index = -1 Then
ListBox1.SelectedIndex = ListBox1.SelectedIndex
Else
ListBox1.SetSelected(index, True)
End If
End Sub
Add New Contact button code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form2.Show()
End Sub
Click on Project menu, then click on the last menu, (in this project: Simple Phone Book Properties)
Then click on Settings tab.
Add Names under Name Column, and System.Collections.Specialized.StringCollection under Type:
Add the following code to Form1.Load event:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
For Each Name As String In My.Settings.Names
ListBox1.Items.Add(Name)
Next
Catch ex As Exception
End Try
End Sub
Add the following code to Remove Contact Button:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ListBox1.SelectedIndex < 0 Then
Else
Dim ask As MsgBoxResult
ask = MsgBox("Are you sure you want to remove " & ListBox1.SelectedItem & " ?", MsgBoxStyle.YesNo)
If ask = MsgBoxResult.Yes Then
My.Settings.Names.Remove(ListBox1.SelectedItem)
My.Settings.Save()
ListBox1.Items.Clear()
For Each Name As String In My.Settings.Names
ListBox1.Items.Add(Name)
Next
ElseIf ask = MsgBoxResult.No Then
End If
End If
End Sub Form2: Add 2 textboxes, 2 labels and 2 buttons:
Cancel Button Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
Save Button Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If My.Settings.Names Is Nothing Then
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("Must Fill all Fields")
Else
My.Settings.Names.Add(TextBox1.Text + " - " + TextBox2.Text)
My.Settings.Save()
Me.Close()
End If
Else
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("Must Fill all Fields")
Else
My.Settings.Names.Add(TextBox1.Text + " - " + TextBox2.Text)
My.Settings.Save()
Me.Close()
End If
End If
TextBox1.Clear()
TextBox2.Clear()
Form1.ListBox1.Items.Clear()
For Each Name As String In My.Settings.Names
Form1.ListBox1.Items.Add(Name)
Next
End Sub
We value our Readers Experience and Feedback.
ReplyDelete