Visual Basic

VISUAL BASIC

Task 1

OpenFileDialog1.Filter = "Text Files|*.txt"

r = OpenFileDialog1.ShowDialog()

If r = Windows.Forms.DialogResult.OK Then

Dim sr As New IO.StreamReader(OpenFileDialog1.FileName)

txtRaw.Text = sr.ReadToEnd()

sr.Close()

strTheLoadedRawFileName = OpenFileDialog1.FileName

strTheLoadedRawFileName = strTheLoadedRawFileName.Substring(strTheLoadedRawFileName.LastIndexOf("\") + 1, strTheLoadedRawFileName.Length - strTheLoadedRawFileName.LastIndexOf("\") - 1)

Me.Text = "HEAD STONES :: " & strTheLoadedRawFileName & ""

ExtractInfo()

DisplayInfo()

End If

Task2

Dim r As DialogResult

OpenFileDialog1.Filter = "Text Files|*.txt"

r = OpenFileDialog1.ShowDialog()

If r = Windows.Forms.DialogResult.OK Then

Dim sr As New IO.StreamReader(OpenFileDialog1.FileName)

txtRaw.Text = sr.ReadToEnd()

sr.Close()

strTheLoadedRawFileName = OpenFileDialog1.FileName

strTheLoadedRawFileName = strTheLoadedRawFileName.Substring(strTheLoadedRawFileName.LastIndexOf("\") + 1, strTheLoadedRawFileName.Length - strTheLoadedRawFileName.LastIndexOf("\") - 1)

Me.Text = "HEAD STONES :: " & strTheLoadedRawFileName & ""

ExtractInfo()

DisplayInfo()

End If

Sometimes, when data is extracted, it can false. I design and impletement to correct when the extracted data is incorrect.

Task3

Dim r As DialogResult

SaveFileDialog1.DefaultExt = ".txt"

SaveFileDialog1.FileName = "Extracted " & strTheLoadedRawFileName

r = SaveFileDialog1.ShowDialog()

If r = Windows.Forms.DialogResult.OK Then

Dim sw As New IO.StreamWriter(SaveFileDialog1.FileName)

Dim aRow As String

Dim i As Integer

For i = 0 To tbl.Rows.Count - 1

aRow = tbl.Rows(i).Item(0) & ", " & tbl.Rows(i).Item(1) & ", " & tbl.Rows(i).Item(2) & ", " & tbl.Rows(i).Item(3)

sw.WriteLine(aRow)

Next

sw.Close()

End If

I design and impletement to save after data is extracted.

Task4

Task4

Dim strSearchName, strSearchDateRange, strSearchAgeAtDeath, strSearchLocation As String

strSearchName = ""

strSearchDateRange = ""

strSearchAgeAtDeath = ""

strSearchLocation = ""

If chkName.Checked = True Then

strSearchName = txtName.Text

End If

If chkAgeAtDeath.Checked = True Then

strSearchAgeAtDeath = chkAgeAtDeath.Text

End If

If chkDateRange.Checked = True Then

strSearchDateRange = txtDateRange.Text

End If

If chkLocation.Checked = True Then

strSearchLocation = chkLocation.Text

End If

Dim ttbbll As New DataTable

ttbbll.Columns.Add("Location")

ttbbll.Columns.Add("PersonName")

ttbbll.Columns.Add("Birth Date")

ttbbll.Columns.Add("Dead Date")

Dim i As Integer, sf As Boolean

For i = 0 To tbl.Rows.Count - 1

sf = True

If strSearchName <> "" Then

If tbl.Rows(i).Item(1) <> strSearchName Then

sf = False

Continue For

End If

End If

If strSearchLocation <> "" Then

If tbl.Rows(i).Item(0) <> strSearchLocation Then

sf = False

Continue For

End If

End If

If strSearchAgeAtDeath <> "" Then

Try

Dim age As Integer, sage As Integer, bd As Date, dd As Date

bd = tbl.Rows(i).Item(2)

dd = tbl.Rows(i).Item(3)

age = dd.Year - bd.Year

sage = Val(strSearchAgeAtDeath)

If age <> sage Then

sf = False

End If

Catch ex As Exception

End Try

End If

If strSearchDateRange <> "" Then

Try

Dim startDate As Date, endDate As Date

Dim strDR As String

strDR = txtDateRange.Text

startDate = strDR.Substring(0, strDR.IndexOf(","))

endDate = strDR.Substring(strDR.IndexOf(",") + 1, strDR.Length - strDR.IndexOf(",") - 1)

Dim deathDate As Date

deathDate = tbl.Rows(i).Item(3)

If deathDate >= startDate And deathDate <= endDate Then

sf = True

End If

Catch ex As Exception

End Try

End If

If sf = True Then

Dim r As DataRow

r = ttbbll.NewRow()

r.Item(0) = tbl.Rows(i).Item(0)

r.Item(1) = tbl.Rows(i).Item(1)

r.Item(2) = tbl.Rows(i).Item(2)

r.Item(3) = tbl.Rows(i).Item(3)

ttbbll.Rows.Add(r)

End If

Next

DataGridView1.DataSource = ttbbll

DataGridView1.DataMember = ttbbll.TableName

DataGridView1.Refresh()

Task5
Task 5

Test name : Head stone Program Test

Test data : Stoke Oats Esfield UK

File Content: Stoke Oats Esfield UK

In / memory of / WENDY-SARAH / SMITH 6th of March 1599/ and HENRY TODOR 28th of January 1547/ Forever in our thoughts / love LIZ and HARRY /

In loving memory / of / JACK McDONALD /aged 3 days / 1799 / Jesus said suffer little / children to come unto Me /

In / loving / memory of / BARRY H / BEAX-SMITH / 1798 – 1882 / PAT C / BEAX-SMITH / 1800 – 1896 /

/ In loving memory / of / SAUL SAM NOCKLEY / late of Shire hall / died Dec 19th 1801, aged 71 years / also GERT NOCKLEY / wife of the above / died Oct 22nd 1811, aged 79 years / peace perfect peace /

Treasured memories of / a loving husband, dad and grandad / JIM WEST / who died 8th March 1780 / aged 80 years / Joined by / a devoted wife, Mum and Nan / JUNE / who died 4th November 1890 / aged 92 years /

In loving memory / of my dear husband / GEORGE WILLIAM HERN / born July 30th 1802 / died August 31st 1872 /

In loving memory of our father WILLIAM JOHN AVALEZ died 2nd March 1904 aged 60 years /And our mother APRIL AVALEZ died 2nd May 1912 aged 74 years /

In loving memory of JOHN CLEMENT died 9th April 1720 aged 14 years /Also of HENRY CLEMENT died 26th March 1748 aged 45 years /

Pray for the repose of the soul of / JAMES BACON / who died 1st February 1892 / aged 24 years / also of Sergeant BILL BACON / killed in action / 26th September 1898 aged 24 years / on whose souls sweet Jesus have mercy / R.I.P / Erected by their sorrowing parents / B and J BACON

Treasured / memories of / JAMES / SNOW / born 22.8.91 / died 23.8.92 / Sleep tight my / precious /

Loving memories / of / ANNE / MURRAY / 11.5.70 / to / 19.4.71 / Sleeping /

First, you will see this when First, you will see this after clicking the file.

After that, choose” Load Raw Data” from file tab.

In this box, choose one that you prefer and then, click “Open”.

Then, you will see the raw data file.

If you want to save data, click Save from File tab.

When you see save dialogue box, click “Save”.

For searching the list you want to find, click “Search” from the Process tab.

If you have a difficulty with this, click About from Help.

Next, you will see the search dialogue box.

Tick the check box and type the name that you want to find.

Then, click “Search” button. It will find that person's data in the search dialogue box.

Tick the check box and type the date range that you want to find.

Then, click “Search” button. It will find that person's data in the search dialogue box and will find below boxes like above.

If you want to close this, click exit from file tab.

Task6
Task6

Installation

1. Click Setup file to install the software.

2. When you see the welcome box, click next.

3. Select the place to install this and click next.

4. After that, you will see this confirmation text and click next

5. After all, the installation is complete and you click close.

Reference

From Visual Basic (Text Book)

Please be aware that the free essay that you were just reading was not written by us. This essay, and all of the others available to view on the website, were provided to us by students in exchange for services that we offer. This relationship helps our students to get an even better deal while also contributing to the biggest free essay resource in the UK!