Introduction: Address Book: Valentines Day Special

Picture of Address Book: Valentines Day Special

This is my address book for windows made in vb 2010 thank you for looking at my instructable

the features are the following:

Save

Open

Merge

Bubble sort

Add

Delete

Edit

the inputs are as follows:

First Name

Last Name

Phone Number

Address

Zip Code

City

State

Hotness Code

Step 1: Form Design

Picture of Form Design

For my form i added the following:

2 listboxes

7 textboxes

4 buttons

1 menustrip with the following items:

File - open, save, and merge

exit

Step 2: Form Properties

Picture of Form Properties

select the label, listboxes, textboxes, buttons, and menustrip and change the forecolor to deep pink (valentines special)

change the fonts to the following:

for listbox2:
Bella Donna, 20pt (20pt may show up as 20.2499981pt)

for everthing else:

Bella Donna, 12PT.

for listbox 2 change the following:

name: hotness

collection to the following:

0

1

2

3

4

5

6

7

8

9

10

picturebox1 property's:

backcolor: transparent

button1:

text: add

name:add

flatstyle: flat

button2:

text: delete

name delete

flatstyle: flat

button3:

text:edit

name: edit

flatstyle: flat

button4:

text: add edit

name: svedit

flatstyle: flat

Step 3: The Code: Dimensions

Picture of The Code: Dimensions

double click form1 and add the following dimensions after "Public Class Form1":

Dim c As Integer = 0


Dim i As Integer = 0

Dim sr As Integer = 0

Dim m As Integer

Dim nd As Integer

Dim sd As Integer

Dim j As Integer

Dim g As Boolean = True

Dim a As Boolean

Dim k As Boolean

Dim lk As String

Dim kl As String

Dim row As String

Dim p As String

Dim gf(8, 5000)

Step 4: The Code: Add_click

Picture of The Code: Add_click

i made the add button click first so that i would be able to add items before i save my addresses

put the following code after the dimensions

double click the add button and add the following code:

k = False

gf(0, i) = lastn.Text

gf(1, i) = firstn.Text

gf(2, i) = num.Text

gf(3, i) = adrs.Text

gf(4, i) = city.Text

gf(5, i) = st.Text

gf(6, i) = zip.Text

gf(7, i) = hotness.SelectedItem

ListBox1.Items.Add(gf(0, i) & " ~~ " & gf(1, i) & " ~~ " & gf(2, i) & " ~~ " & gf(3, i) & " ~~ " & gf(4, i) & " ~~ " & gf(5, i) & " ~~ " & gf(6, i) & " ~~ " & gf(7, i))

i += 1

sort()

Step 5: The Code: Delete_click

Picture of The Code: Delete_click

after the add click code add the following code:

Private Sub delete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles delete.Click
sd = ListBox1.SelectedIndex

For q = sd To i - 2

For l = 0 To 7

gf(l, q) = gf(l, q + 1)

Next

Next

If i > 0 Then i -= 1

ListBox1.Items.Remove(ListBox1.SelectedItem)

End Sub

Step 6: The Code: Edit_click

Picture of The Code: Edit_click

after the delete_click code add the following:

Private Sub edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit.Click
sd = ListBox1.SelectedIndex

svedit.Visible = True

add.Visible = False

delete.Visible = False

edit.Visible = False

lastn.Text = gf(0, sd)

firstn.Text = gf(1, sd)

num.Text = gf(2, sd)

adrs.Text = gf(3, sd)

city.Text = gf(4, sd)

st.Text = gf(5, sd)

zip.Text = gf(6, sd)

hotness.SelectedItem = gf(7, sd)

End Sub

Step 7: The Code: Svedit

Picture of The Code: Svedit

after the edit_click code add the following

Private Sub svedit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles svedit.Click
svedit.Visible = False

add.Visible = True

delete.Visible = True

edit.Visible = True

gf(0, sd) = lastn.Text

gf(1, sd) = firstn.Text

gf(2, sd) = num.Text

gf(3, sd) = adrs.Text

gf(4, sd) = city.Text

gf(5, sd) = st.Text

gf(6, sd) = zip.Text

gf(7, sd) = hotness.SelectedItem

ListBox1.Items(sd) = lastn.Text & " ~~ " & firstn.Text & " ~~ " & num.Text & " ~~ " & adrs.Text & " ~~ " & city.Text & " ~~ " & st.Text & " ~~ " & zip.Text & " ~~ " & hotness.SelectedItem

sort()

End Sub

Step 8: The Code: Save

Picture of The Code: Save

after the svedit click add the following:

Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
SaveFileDialog1.ShowDialog() 'shows savedialog

p = SaveFileDialog1.FileName

Dim objReader As New System.IO.StreamWriter(p)

ad()

objReader.Close() 'closes savedialog

k = True

If k = True Then Label2.Visible = True

sort()

End Sub

Step 9: The Code: Open

Picture of The Code: Open

after the save code add the following:

Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
OpenFileDialog1.Filter = "data|*.txt|all|*.*" 'shows only .txt files

OpenFileDialog1.ShowDialog() 'shows opendialog

p = OpenFileDialog1.FileName

c = 0 'reset c counter to 0

Dim s As New System.IO.StreamReader(p)

Do Until s.EndOfStream

row = s.ReadLine

For l = 0 To 7

gf(l, c) = row.Split(",")(l)

Next

c += 1

Loop

s.Close() 'closes opendialog

ListBox1.Items.Clear()

ad()

sort()

End Sub

Step 10: The Code: Merge

Picture of The Code: Merge

after the open code add: copy the open code and past it for the merge tool strip item and delete "c=0" and change the c += 1 to i += 1

Step 11: The Code: Suberteens and Exit

Picture of The Code: Suberteens and Exit

at the end just before "end class" add the following:

Private Sub sort()
g = True

Do Until g = False

g = False

For y = 0 To i - 2

If UCase(gf(0, y)) > UCase(gf(0, y + 1)) Then

g = True

For x = 0 To 7

kl = gf(x, y)

gf(x, y) = gf(x, y + 1)

gf(x, y + 1) = kl

Next

End If

Next

Loop

ListBox1.Items.Clear()

For nm = 0 To i - 1

ListBox1.Items.Add(gf(0, nm) & " ~~ " & gf(1, nm) & " ~~ " & gf(2, nm) & " ~~ " & gf(3, nm) & " ~~ " & gf(4, nm) & " ~~ " & gf(5, nm) & " ~~ " & gf(6, nm) & " ~~ " & gf(7, nm))

Next

End Sub

Private Sub ad()

For r = 0 To i - 1

ListBox1.Items.Add(gf(0, r) & " ~~ " & gf(1, r) & " ~~ " & gf(2, r) & " ~~ " & gf(3, r) & " ~~ " & gf(4, r) & " ~~ " & gf(5, r) & " ~~ " & gf(6, r) & " ~~ " & gf(7, r)) 'add array items into listbox1

Next

End Sub

Private Sub ExitToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem1.Click

If k = False Then a = (MsgBox("Are you sure you want to exit", vbYesNo) - 6) Else End

If a = False Then End

End Sub

Comments

About This Instructable

377views

2favorites

More by kooljo:Address book: Valentines day specialAtari Combat: Tank vb 2010
Add instructable to: