Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,616
- Office Version
- 365
- 2016
- Platform
- Windows
Consider this code.
I am getting an error ("Case without Select Case") with the line in red. I'm unable to test the rest of my code until I can correct this error, but I don't understand what is causing it. The variable db_fix_type should be a number between 1 and 7 as calculated.
Rich (BB code):
Sub Fix_Properties()
Dim fix_name As String
Dim len_fn As Long
Dim db_fix_type As Double
Dim txt_fix_type As String
Dim fix_type As String
Dim response
Dim NavUpper As Integer, NavLower As Integer
Dim txt_freq As String
Dim freq As Integer
Dim freqlen As Double
Dim freqval As Boolean
fix_name = ""
len_fn = 0
NavLower = 108
NavUpper = 117.975
CHspac = 25 'khz
freqlen = 0
freqval = True
Do
fix_name = InputBox("Enter the fix name: ", "FIX NAME")
len_fn = Len(fix_name)
If len_fn < 2 Then
response = MsgBox("Fix names must be 2 or more characters in length. Please Try again.", 17, "ERROR: Fix Name")
If response = 2 Then Exit Sub
End If
Loop Until len_fn > 1
Do
txt_fix_type = InputBox("Enter the fix type: " & Chr(13) & "1 - NDB" & Chr(13) & "2 - VOR" & Chr(13) & "3 - SID Fix" & Chr(13) & "4 - ARR Fix" & Chr(13) & "5 - Aerodrome" & Chr(13) & "6 - Airway Fix" & Chr(13) & "7 - Fix", "FIX NAME")
db_fix_type = txt_fix_type * 1
If db_fix_type < 1 Or db_fix_type > 7 Then
response = MsgBox("Please select one of the 7 recognized fix types. Please Try again.", 17, "ERROR: Fix Type")
If response = 2 Then Exit Sub
End If
Loop Until db_fix_type > 0 And db_fix_type < 8
Select Case db_fix_type
Case 1
fix_type = "NDB"
Do
txt_freq = InputBox("Enter the NDB frequency: ", "NDB Frequency", "000.0000")
'check valid numeric value
If IsError(txt_freq * 1) Then
freqval = False
MsgBox "Invalid frequency (Non numeric)"
End If
int_freq = txt_freq * 1
' length
freqlen = Len(freq)
If freqlen <> 8 Then
freqval = False
MsgBox "Improper length."
End If
' has decimal character
If IsError(decloc = InStr(freq, ".", vbTextCompare)) Then
freqval = False
MsgBox "Improper frequency format (no decimal)"
End If
decloc = InStr(freq, ".", vbTextCompare)
' decimal location
If decloc <> 4 Then
freqval = False
MsgBox "Improper frequency format (decimal)"
End If
' MHz
If decloc - 1 <> 3 Then
freqval = False
MsgBox "Improper frequency format (MHz 000.)"
End If
' KHz
If decloc - 1 <> 3 Then
freqval = False
MsgBox "Improper freq format (KHz .0000)"
End If
' freq within aeronautical range
If int_freq < NavLower Or int_freq > NavUpper Then
freqval = False
MsgBox "Invalid frequency (Out of range 108.0000MHz - 117.9750 MHz)"
End If
' freq fit within channel spacing
khzfreq = int_freq * 1000
If khzfreq Mod CHspac <> 0 Then
freqval = False
MsgBox "Invalid frequency (Channel Spacing 25KHz)"
End If
Do Until freqval = True
int_freq = Round(int_freq, 4)
MsgBox "Valid NDB Frequency" & Chr(13) & int_freq & " MHz"
Case 2
fix_type = "VOR"
Case 3
fix_type = "SID Fix"
Case 4
fix_type = "ARR Fix"
Case 5
fix_type = "Aerodrome"
Case 6
fix_type = "irway Fix"
Case Else
fix_type = "Fix"
End Select
MsgBox "Fix Type: " & fix_type
End Sub
I am getting an error ("Case without Select Case") with the line in red. I'm unable to test the rest of my code until I can correct this error, but I don't understand what is causing it. The variable db_fix_type should be a number between 1 and 7 as calculated.