You are on page 1of 3

'Aerial Photo Scale

'The purpose of this assignment is to create a scale calculator that calculates scale
based on flying height, focal length and elevation
'Michael Wszol
'November 13, 2014
Public Class txtfocallength
Private Sub btnCalculate_Click(ByVal sender As Object, e As EventArgs) Handles
btnCalculate.Click
'This is the calculate button and all the codes underneath work towards make the
button work correctly
txtScale.Enabled = True
'This code is means that the txt scale is being enabled and true so that it works
compared to it being false and this feature will not be enabled to work
Dim strFocalLength1 As String
Dim decFocalLength1 As Decimal
Dim strFlyingHeight As String
Dim decFlyingHeight As Decimal
Dim strElevation As String
Dim decElevation As Decimal
Dim decScale As Decimal
Dim intScale As Integer
'All these codes declaire their meaning and what type of variable they are
'These next three codes classify the texbox to be a string.
strFocalLength1 = Me.txtFocalLength1.Text
strFlyingHeight = Me.txtFlyingHeight.Text
strElevation = Me.txtElevation.Text

If IsNumeric(txtFocalLength1.Text) Then
decFocalLength1 = Convert.ToDecimal(strFocalLength1)
' if the user enters a non numeric number for focal length then the error box
will pop up
Else : MsgBox("Error! Enter a numerical focal length value.")
' this is the msgbox and what the box will say if it does appear
txtFocalLength1.Focus()
'this code tells the cursure to focus back to the focal legnth txtbox
txtFocalLength1.Clear()
' this code tells the text box of the focal length to clear if the value
entered is incorrect
Return
' this return tells the code to run agian if needed
End If
' this ends the if statement
If decFocalLength1 >= 1 And decFocalLength1 <= 99.9 Then
' this code is giving the focal length a validation rule and means the user
has to enter a value between this range
decFocalLength1 = txtFocalLength1.Text
' this is converting a textbox into a decimal
Else : MsgBox("Error! Please enter a focal length between 0.1 and 99.9.")
'This is another message box when an error occurs
txtFocalLength1.Focus()
' this focus back onto the focal length text box
txtFocalLength1.Clear()

' this clears the focal length box


Return
End If
If IsNumeric(txtFlyingHeight.Text) Then
decFlyingHeight = Convert.ToDecimal(strFlyingHeight)
'this is converting a string to a decimal
Else : MsgBox("Error! Please enter a correct value for flying Height.")
txtFlyingHeight.Focus()
txtFlyingHeight.Clear()
Return
End If
If decFlyingHeight >= 1 And decFlyingHeight <= 1000000 Then
'this is another validation rule and a range which the value has to be
inbetween
decFlyingHeight = txtFlyingHeight.Text
Else : MsgBox("Error! Enter a flying height between 1 and 1,000,000.")
' this is the error for the range
txtFlyingHeight.Focus()
'this focuses back to the flying height text
txtFlyingHeight.Clear()
'this clears the textbox for the flying height
Return
End If
If IsNumeric(txtElevation.Text) Then
decElevation = Convert.ToDecimal(strElevation)
Else : MsgBox("Error! Please enter a correct elevation numerical value.")
'indicating that the elevation has to be a numerical value
txtElevation.Focus()
txtElevation.Clear()
End If
If decElevation >= 0 And decElevation <= 9000 Then
'Another validation rule and that if the value is not in the range the
program will not work
decElevation = Convert.ToDecimal(strElevation)
Else : MsgBox("Error! Enter an elevation between 0 and 9000.")
'the msgbox that will occur if it does not work
txtElevation.Focus()
txtElevation.Clear()
Return
End If
If decFlyingHeight - decElevation > 0 Then
' Another validation rule for the elevation and that it has to follow or else
it will not work
Else : MsgBox("Error! Enter a new elevation value lower then flying height
value.")
txtElevation.Focus()
txtElevation.Clear()
Return
End If
decScale = (decFlyingHeight - decElevation) / (decFocalLength1 / 100)

' this is the formula for the entire calculate button and this is how we get a
scale value
intScale = Convert.ToInt64(decScale)
Me.txtScale.Text = "1:" & intScale.ToString
' this is indicating that the scale value is decimal and it is being converted
from an integer to a decimal

End Sub
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles
lblFocalLength.Click
'this is the label for focal length
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnClear.Click
' This Clears all of the text boxes if they had values in them
Me.txtFocalLength1.Clear()
Me.txtFlyingHeight.Clear()
Me.txtElevation.Clear()
Me.txtScale.Clear()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnExit.Click
' this code is the exit button and when clicked on it closes the program
Me.Close()
'when this is clicked the program shuts down
End Sub
End Class

You might also like