Anda di halaman 1dari 2

Option Strict On Public Class MapForm 'Program Name: Map Scale Calculator 'Author: Shannon Graup 'Date: November

14, 2013 'Purpose: This windows application will calculate the scale of an airphoto in meters with user inputs of focal length, flying height and elevation. Private Sub BtnCalculate_Click(sender As System.Object, e As System.EventArgs) Handles BtnCalculate.Click 'Declaration of variables Dim decFocalLength, decFlyingHeight, decElevation As Decimal Dim strlblFocalLength, strlblFlyingHeight, strlblElevation As String Dim decAirPhotoScale As Decimal 'Declare focal length entered in text box as the strFocalLength strlblFocalLength = Me.FocalLength.Text 'If statements checking user entered value is a numeric value, and inside a numeric range If IsNumeric(strlblFocalLength) = False Then MsgBox("Please enter a numeric focal length", MsgBoxStyle.RetryCancel, "Focal Length Error") FocalLength.Focus() FocalLength.SelectAll() Return ElseIf CDbl(strlblFocalLength) < 0.1 Or CDbl(strlblFocalLength) > 99.9 Then MsgBox("Please enter focal length between 0.10 and 99.90 cm", MsgBoxStyle.RetryCancel, "Focal Length Error") FocalLength.Focus() FocalLength.SelectAll() Return Else decFocalLength = Convert.ToDecimal(strlblFocalLength) End If 'Declare flying height entered in text box as the strFlyingHeight strlblFlyingHeight = Me.FlyingHeight.Text 'If statements checking user entered value is a numeric value, and inside a numeric range If IsNumeric(strlblFlyingHeight) = False Then MsgBox("Please enter a numeric flying height", MsgBoxStyle.RetryCancel, "Flying Height Error") FlyingHeight.Focus() FlyingHeight.SelectAll() Return ElseIf CDbl(strlblFlyingHeight) < 1.0 Or CDbl(strlblFlyingHeight) > 1000000.0 Then MsgBox("Please enter a flying height between 1.0 and 1000000.0 cm", MsgBoxStyle.RetryCancel, "Flying Height Error") FlyingHeight.Focus() FlyingHeight.SelectAll() Return Else decFlyingHeight = Convert.ToDecimal(strlblFlyingHeight) End If

'Declare elevation entered in text box as the strElevation strlblElevation = Me.Elevation.Text 'If statements checking user entered value is a numeric value, inside a numeric range and flying height is greater than elevation If IsNumeric(strlblElevation) = False Then MsgBox("Please enter a numeric elevation", MsgBoxStyle.RetryCancel, "Elevation Error") Elevation.Focus() Elevation.SelectAll() Return ElseIf CDbl(strlblElevation) < 0.0 Or CDbl(strlblElevation) > 9000.0 Then MsgBox("Please enter an elevation between 0.10 and 99.90 cm", MsgBoxStyle.RetryCancel, "Elevation Error") Elevation.Focus() Elevation.SelectAll() Return ElseIf strlblElevation >= strlblFlyingHeight Then MsgBox("Please enter an elevation higher than the flying height (Flying height - elevation cannot be less than 0)", MsgBoxStyle.RetryCancel, "Elevation Error") Elevation.Focus() Elevation.SelectAll() Return Else decElevation = Convert.ToDecimal(strlblElevation) End If 'Calculate air photo scale using formula S = f / (H - e) and put string into textbox decAirPhotoScale = (1 / ((decFocalLength / 100) / ((decFlyingHeight) (decElevation)))) Me.AirPhotoScale.Text = decAirPhotoScale.ToString("1: ###,###,###") End Sub Private Sub BtnClear_Click(sender As System.Object, e As System.EventArgs) Handles BtnClear.Click 'This button will clear all of the text boxes of any text entered by user FocalLength.Clear() FlyingHeight.Clear() Elevation.Clear() AirPhotoScale.Clear() End Sub End Class

Anda mungkin juga menyukai