1. Introduction
This is our first individual assignment for Programming unit this semester. This assignment was given in December 2013, and submission date is on 10th February 2014.
In this assignment, we were asked to create and design a Photo Viewer application. This application should be able to allow the users to browse through pre-loaded images. Programming will be done using Visual Basic.NET 2008 software.
At the end of the assignment, we should be able to produce documentation on Photo Viewer application.
2. Design Structure
2.1 Layout Form 1
Below is the layout of Form 1:
Button 1: “Add” button – used to add images.
Button 2: “Save” button – used to save new images.
Button …show more content…
Here is the coding listing for Form 1:
Imports System.IO
Public Class Form1 Dim filename As String Dim strdirectory As String = "\VB\Photo Viewer\"
Private Sub save_record()
Dim opentext As StreamWriter If File.Exists(strdirectory & "photos.txt") Then opentext = File.AppendText(strdirectory & "photos.txt") Else opentext = File.CreateText(strdirectory & "photos.txt") End If
opentext.WriteLine(txtimgno.Text) opentext.WriteLine(txtcaption.Text) opentext.WriteLine(txtdate.Text) opentext.WriteLine(rtbDescription.Text) opentext.WriteLine() opentext.Close() pbxPhoto.Image.Save(strdirectory & "images\" & txtimgno.Text & ".jpg") MsgBox("Image saved!", MsgBoxStyle.Information) gbxDetails.Enabled = False btnSAVE.Enabled = False btnCancel.Enabled = False gbxDetails.Enabled = False btnADD.Enabled = True btnVIEW.Enabled = True btnExit.Enabled = True
txtcaption.Clear() txtdate.Text = "" txtimgno.Clear() rtbDescription.Clear() pbxPhoto.Image = Nothing filename = …show more content…
.ShowDialog() If .FileName = "" Then MsgBox("No image selected!") Else filename = .FileName pbxPhoto.Image = Image.FromFile(filename) gbxDetails.Enabled = True btnSAVE.Enabled = True btnCancel.Enabled = True btnADD.Enabled = False btnVIEW.Enabled = False btnExit.Enabled = False
End If End With End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click Dim x As Integer x = MsgBox("Cancel adding picture?", MsgBoxStyle.Question + MsgBoxStyle.OkCancel)
If x = vbOK Then gbxDetails.Enabled = False btnSAVE.Enabled = False btnCancel.Enabled = False gbxDetails.Enabled = False btnADD.Enabled = True btnVIEW.Enabled = True btnExit.Enabled = True
txtcaption.Clear() txtdate.Text = "" txtimgno.Clear() rtbDescription.Clear() pbxPhoto.Image =