-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.vb
More file actions
73 lines (61 loc) · 2.25 KB
/
Copy pathProgram.vb
File metadata and controls
73 lines (61 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Imports System
Module Program
Sub Main()
Dim Bearing1 As Integer = 0 ' bearing from left ref point to target
Dim Bearing2 As Integer = 0 ' bearing from right ref point to target
Dim RefDistance As Integer = 0 ' distance between two ref points
Dim RangeToTarget As Double = 0 ' Calculated range
Dim tmpAngle As Integer = 0
Dim OutTxt(2) As String
Dim ProgVer As String = "1.0.12"
Dim inputStr As String = ""
OutTxt(0) = "+------------------------------[{0,6}]----------------------------+"
OutTxt(1) = "| Range Calculator - by John Dovey <dovey.john@gmail.com> |"
OutTxt(2) = "| View the code on GitHub [https://github.com/JohnDovey/RangeCalc] |"
Console.WriteLine(OutTxt(0), ProgVer)
Console.WriteLine(OutTxt(1))
Console.WriteLine(OutTxt(2))
Console.WriteLine(OutTxt(0), ProgVer)
Console.WriteLine(vbLf & vbLf & " Enter the values as prompted")
' Bearing One
Console.Write("Bearing from Ref One to Target: ")
inputStr = Console.ReadLine
Bearing1 = Val(inputStr)
Console.WriteLine(vbTab & "({0} degrees bearing Ref 1 to target) ", Bearing1)
If Bearing1 > 360 Then
Console.WriteLine("Error! No more than 360 Degrees allowed")
Exit Sub
End If
If Bearing1 < 1 Then
Console.WriteLine("Error! Bearing must be greater than zero")
Exit Sub
End If
' Bearing Two
Console.Write("Bearing from Ref Two to Target: ")
inputStr = Console.ReadLine
Bearing2 = Val(inputStr)
Console.WriteLine(vbTab & "({0} degrees bearing Ref 2 to target) ", Bearing2)
If Bearing2 > 360 Then
Console.WriteLine("Error! No more than 360 Degrees allowed")
Exit Sub
End If
If Bearing2 < 1 Then
Console.WriteLine("Error! Bearing must be greater than zero")
Exit Sub
End If
' Seperation Distance
Console.Write("Distance between Ref One and Ref Two: ")
inputStr = Console.ReadLine
RefDistance = Val(inputStr)
Console.WriteLine(vbTab & "({0} meters between reference points) ", RefDistance)
' d = (Tan (90 - (A -B))) x Ref
tmpAngle = Bearing1 - Bearing2
If tmpAngle < 0 Then
tmpAngle *= (0 - 1)
End If
RangeToTarget = (Math.Tan(90 - tmpAngle)) * RefDistance
Console.WriteLine("Range to Target: {0}", RangeToTarget)
Console.Write("Hit a key (softly) to continue")
Console.ReadKey()
End Sub
End Module