Phone Book Application Program In Visual Basic 2008/2010/.NET - VB Tutorials - Basics Projects

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:


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

Related

Visual Basic 2008 2941309177230505182

Post a Comment

SPAMMING will not be Appreciated.

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

Hot in weekRecentComments

Hot in week

Recent

C Programming - Data Structure Interview Questions Answer

We have started series of C programming Q&A for job interview for freshers.Computer / IT Engineering Professionals and Students alike will be benefited.We recommend our user to go through pre...

C Programming Question Answer

We have started series of C programming Q&A for job interview candidates.Engineering Professionals and students alike will be benefited.We recommend our user to go through previous post to enha...

Java Objective Multiple Answer Questions Bank

We have chosen Java Oracle J2EE, J2SE, Net-beans, JVM ( Java Virtual Machine ) as our readers choice.We have created Objective Type Multiple Answer Question Collection that are frequent in job inte...

Java Question Bank Objective Q&A

Here we have collected frequently asked question in job interviews.We have chosen Java as our readers choice.You will find these helpful.We encourage our Readers to send in their suggestion. If re...

C Question Bank

We have started series of C programming Question bank for job interview candidates.Engineering Professionals and students alike will be benefited.We encourage our readers to provide feedback and as...

Comments

Anonymous:

Technology is always being the vital part of evolution either mobile phones or computer all are the part of it. Electronics have made things so easy and reliable for human being s. very few schools in...

Anonymous:

A detailed and complete knowledge guide for fresher's to crack their interviews in Embedded Programming. Looking for a job contact <a href="http:/celebratejobs.com/>celebratejobs</a&...

YouLoseBellyFat:

visual basic example codes

App Development Mumbai:

It was very useful for me. Keep sharing such ideas in the future as well. This was actually what I was looking for, and I am glad to came here! Thanks for sharing the such information with us.

Anonymous:

Thanks for Appreciations.We love to hear again from you.

Our Channel

Contact Us

Name

Email *

Message *

item