Abstract: When the Manage Photos form is opened, functionally a txt file name Sample.txt is save in Photo Manage folder located in C drive. If we delete this file by DELETE button, we can also create a file with CREATE button. After the txt file is created, now we can browse a picture file with the BROWSE button. When selection picture is completed, selected picture file path is show in the text box. After that, we have to name the picture file, what we want to give. Then the date the photograph was taken and the location, where the photograph was taken. Also, we can give the weather condition at the time, when the photograph was taken. Finally we have to save the photo by clicking on the SAVE button and if we want to add other photograph information, we have to click CLEAR button to clear the form and the ADD button for adding later information. Also read the file by OPEN button.
Comment : This is an easiest way to save, add and open our photograph information by this short process.
Object Definition Sheet :
No.
Type
Property
Value
Event Procedure
01.
MenuStrip
Name
Menu Strip1
FileToolStripMenuItem_Click
02.
Label
Name
Label1
Label1_Click
03.
Label
Name
Label2
Label2_Click
04.
Label
Name
Label3
Label3_Click
05.
Label
Name
Label4
Label4_Click
06.
Label
Name
Label5
Label5_Click
07.
Label
Name
Label6
Label6_Click
08.
Label
Name
Label7
Label7_Click
09.
Text Box
Name
txtPhotoName
txtPhotoName _TextChanged
10.
Text Box
Name
txtPhotoPath
txtPhotoPath _ TextChanged
11.
Text Box
Name
txtPhotoLocation
txtPhotoLocation_TextChanged
12.
Text Box
Name
txtView
txtView _ TextChanged
13.
Button
Name
btnBrowse
btnBrowse _Click
14.
Button
Name
btnRead
btnRead _Click
15.
Button
Name
btnNew
btnNew _Click
16.
Button
Name
btnSave
btnSave _Click
17.
Button
Name
btnAdd
btnAdd _Click
18.
Button
Name
btnDelete
btnDelete _Click
19.
Button
Name
btnCreate
btnCreate _Click
20.
Button
Name
btnSearch
btnSearch _Click
21.
Picture Box
Name
PictureBox1
PictureBox1_Click
Correct Interface and Logic :
Figure
First we have to create a folder named Photo Manage in C drive. Then we have to run this application. We will see a form, which title is Mark’s Photography Library.
A menu strip is included with this form. This menu strip shows a drop down list, which contain three items. First one is for manage photography information, second one is for searching text, which are saved by user and the third one is for quit.
Figure 5
After we click on the drop down list Manage Photos items, a form titled Manage Photos will appear. Functionally a txt file named Sample.txt will be saved in Photo Manage folder located in C drive. In that position if we click on the create button, a message box will appear and give an information. If we click on the delete button one more information will be showed by message box. After that, if we click again on delete button message box will be showed again with a one more information.
Figure 6
Figure 8
Figure 7
Then we will click on the button named browse, which will show an open file dialog. What we have to do, it’s showing the photo file path. After this, the photo will functionally show in picture box and the photo file path will show in text box. If we do not select a directory, one more message box will show with information.
Figure 9
Figure 10
Figure 12
After selection, we have to write the photo name in name text box. Also we have to pick the date when the photo was taken and make sure what the location is and what is the weather.
Figure 11
Figure 15
Figure 14
When all the information are given, we will save the information by click on the save button. New button is for clear the form and also if we want to add more information we can use add button. Without creating the txt file, if we click on the save button a message box will show again and give what have to do for save our document. If we do not create txt file and click on the add button, it will automatically create a txt file and then add the documents we want to save.
Figure 13
After all these, now have to time for read the text we saved. If we have to read what we saved, then we have to click on the button named Read. When we click on read button, the saved text file will show in a text box, which is above of picture box and before that a message box will show, the file read has been successful. But if the txt file is not found or create, then a message box will tell us what is missing.
Figure 17
Figure 16
Figure 18
Later then, when we have to search our text, we have to go in search form. There is a button named search, which is for searching the text we saved. Click on search button will show the input box, what will say us to input the text, what we want to search in the text file. It will search our text line by line reading, when the matching text is found, it will show that by a message box.
Figure 20
Figure 19
Figure 21
In the input text dialog, we input the text Friday, what we want to search. When we click on ok button the result of our search is showed by a message box.
Implementation
Variable Naming :
Dim arrCounter
Dim objWriter
Dim strTextToSearch
Dim strTextFileInfo()
Dim objReader
Variable Type :
As New System.IO.StreamReader(FILE_NAME)
As String
As New System.IO.StreamWriter(FILE_NAME)
As New FileStream
As Integer
As New frmSearch()
Variable Value Right Position :
Dim strTextToSearch As String = String.Empty
Dim strTextFileInfo() As String
Dim arrCounter As Integer = 0
Dim myForm As New frmSearch()
Dim intrebare As String
IF THEN ELSE (Correct Use) :
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objReader As New System.IO.StreamReader(FILE_NAME)
txtView.Text = objReader.ReadToEnd
objReader.Close()
MessageBox.Show("File Has Been Read Successfully")
Else
MessageBox.Show("Please Create The Text File First")
End If
Looping (Correct Use) :
Do While objReader.Peek <> -1
ReDim Preserve strTextFileInfo(arrCounter)
strTextFileInfo(arrCounter) = objReader.ReadLine
arrCounter = arrCounter + 1
Loop
For i As Integer = 0 To arrCounter - 1
If strTextFileInfo(i).ToLower.Contains(strTextToSearch.ToLower) Then
MessageBox.Show(strTextFileInfo(i))
End If
Next
Error Capture :
1. When the text file is not exist and click on the delete button, then a message box show the error capture.
Figure 22
2. When the text file is not exist and click on the read button, then a message box show the error capture.
Figure 23
Figure 24
3. When the text file is not exist and click on the save button, then a message box show the error capture.
4. When the browse button is click but do not select a directory, then a message box show the error capture.
Figure 25
Suitable Data Display :
1. We fill the form with our information and then click on the button for save our information. After saving, we want to open our saved information. Click on the read button will show what we saved in our text file.
Figure 26
Figure 27
2. Later then, when we want to search the text we saved. Click on the search button will show the result by message bar.
Figure 30
Figure 29
Figure 28
Data Capture :
1. We saved the information we write and read the information in text box.
Figure 31
2. We input the text we want to search, and we see that by message box.
Figure 32
Explanations (Comments) :
Figure 33
Figure 34
Testing
1. When we click on the exit option of Mark’s Photography Library, we are quite. If no then the application will run.
Figure 35
Figure 37
2. Click on the browse button will show a dialog box, for selection the photo file path.
Figure 36
3. When the photo was taken, we can add the date by click on the date time picker
4. We can attach the weather, when the photo was taken.
5. We can input the name of the picture and also input the location, where the picture was taken.
6. After that we click on the save button, text are saved in the text file and we can read this text, what we input by click on the read button.
7. We can add more photo information by click on the add button and read the added text information.
Figure 38
8. Followed by, we can clear the form by click on the button new, to add more photo information.
9. In the search form we input the text we want to search in this text file and its shows the result in message box.
Figure 39
10. In the manage photos form we can create the file by click on the button named create.
11. Once we create the file, we can also delete it by click on the button named delete.
Figure 40
Future Improvement :
In the search form, there are two error, these are not completed. When there is no text file, the search button does not give such information and when the input box is empty its read all the line functionally. I apologize for this; in the future I will complete the whole application.
Figure 41