Sie sind auf Seite 1von 2

' Assignment 2: VB.

Net Application Development


' Purpose: To understand basic programming through designing, planning and developing a
VB.Net solution.
' Created by: Winona Drouin
' Date: December 11, 2017

Public Class MapScale


Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles
btnCalculate.Click
' This button calculates the scale based on Focal Length, Flying Height and
Elevation.

' Set the string variable called FocalLength, FlyingHEight and Elevation.
Dim strFocalLength, strFlyingHeight, strElevation As String

' Set the decimal variable called FocalLength, FlyingHeight and Elevation.
Dim decFocalLength, decFlyingHeight, decElevation As Decimal
' Set the integer variable called Scale.
Dim intScale As Integer

'Convert strings to decimals.


strFocalLength = Me.txtFocalLength.Text
decFocalLength = Convert.ToDecimal(strFocalLength)

strFlyingHeight = Me.txtFlyingHeight.Text
decFlyingHeight = Convert.ToDecimal(strFlyingHeight)

strElevation = Me.txtElevation.Text
decElevation = Convert.ToDecimal(strElevation)

' FocalLength input error checks.


If IsNumeric(txtFocalLength.Text) = False Then
' If the user enters in an incorrect number:
MsgBox("Focal length input error. Please enter in a valid number.")
'If the user enters in a value less than 0.1 and larger than 99.9:
ElseIf txtFocalLength.Text <= 0.1 Or txtFocalLength.Text >= 99.9 Then
MsgBox("Focal length input error. Please enter in a value between 0.1 and
99.9")
End If

' FlyingHeight input error checks.


If IsNumeric(txtFlyingHeight.Text) = False Then
' If the user enters in an incorrect number:
MsgBox("Flying height input error. Please enter in a valid number.")
' If the user enters in a value less than 1.0 and larger than 1,000,000.0
ElseIf txtFlyingHeight.Text <= 1.0 Or txtFlyingHeight.Text >= 1000000.0 Then
MsgBox("Flying height input error. Please enter in a value between 1.0 and
1,000,000.0")
End If

' Elevation input error checks.


If IsNumeric(txtElevation.Text) = False Then
' If the user enters in an incorrect number:
MsgBox("Elevation input error. Please enter in a valid number.")
ElseIf txtElevation.Text <= -413.0 Or txtElevation.Text >= 8848.0 Then
MsgBox("Elevation input error. Please enter a value between -413.0 and
8848.0")
End If

intScale = (1 / ((decFocalLength / 100) / (decFlyingHeight - decElevation)))

Me.txtScaleRatio.Text = intScale.ToString("1:###,###,###")

If (decFlyingHeight - decElevation) <= 0 Then


MsgBox("Input error. Elevation must be lower than Flying Height")
End If

End Sub

Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click


' This button will clear all data within the Focal Length, Flying Height, and
Elevation text boxes.
Me.txtFocalLength.Clear()
Me.txtFlyingHeight.Clear()
Me.txtElevation.Clear()
lblScale.Text =
Me.txtFocalLength.Focus
End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click


' This button will exit the application.
Me.Close()
End Sub
End Class

Das könnte Ihnen auch gefallen