VERSION 5.00
Begin VB.Form setupfrm3 
   Caption         =   "Form1"
   ClientHeight    =   3225
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9990
   LinkTopic       =   "Form1"
   ScaleHeight     =   3225
   ScaleWidth      =   9990
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox fste2 
      Height          =   495
      Left            =   4920
      TabIndex        =   16
      Text            =   "0.1"
      Top             =   1440
      Width           =   1215
   End
   Begin VB.TextBox fsto2 
      Height          =   495
      Left            =   4920
      TabIndex        =   15
      Text            =   "1"
      Top             =   840
      Width           =   1215
   End
   Begin VB.TextBox fsta2 
      Height          =   495
      Left            =   4920
      TabIndex        =   14
      Text            =   "0.1"
      Top             =   240
      Width           =   1215
   End
   Begin VB.TextBox fste3 
      Height          =   495
      Left            =   8160
      TabIndex        =   10
      Text            =   "1"
      Top             =   1440
      Width           =   1215
   End
   Begin VB.TextBox fsto3 
      Height          =   495
      Left            =   8160
      TabIndex        =   9
      Text            =   "18"
      Top             =   840
      Width           =   1215
   End
   Begin VB.TextBox fsta3 
      Height          =   495
      Left            =   8160
      TabIndex        =   8
      Text            =   "2"
      Top             =   240
      Width           =   1215
   End
   Begin VB.ComboBox cboFreq 
      Height          =   315
      ItemData        =   "setupfrm3.frx":0000
      Left            =   4680
      List            =   "setupfrm3.frx":000D
      Style           =   2  'Dropdown List
      TabIndex        =   7
      Top             =   2520
      Width           =   1215
   End
   Begin VB.TextBox fsta1 
      Height          =   495
      Left            =   1800
      TabIndex        =   3
      Text            =   "0.045"
      Top             =   240
      Width           =   1215
   End
   Begin VB.TextBox fsto1 
      Height          =   495
      Left            =   1800
      TabIndex        =   2
      Text            =   "0.05"
      Top             =   840
      Width           =   1215
   End
   Begin VB.TextBox fste1 
      Height          =   495
      Left            =   1800
      TabIndex        =   1
      Text            =   "0.005"
      Top             =   1440
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   495
      Left            =   2880
      TabIndex        =   0
      Top             =   2400
      Width           =   1215
   End
   Begin VB.Label Label9 
      Caption         =   "Start"
      Height          =   375
      Left            =   3360
      TabIndex        =   19
      Top             =   360
      Width           =   1215
   End
   Begin VB.Label Label8 
      Caption         =   "Stop"
      Height          =   375
      Left            =   3360
      TabIndex        =   18
      Top             =   840
      Width           =   1215
   End
   Begin VB.Label Label7 
      Caption         =   "Step"
      Height          =   495
      Left            =   3360
      TabIndex        =   17
      Top             =   1440
      Width           =   1215
   End
   Begin VB.Label Label6 
      Caption         =   "Start"
      Height          =   375
      Left            =   6600
      TabIndex        =   13
      Top             =   360
      Width           =   1215
   End
   Begin VB.Label Label5 
      Caption         =   "Stop"
      Height          =   375
      Left            =   6600
      TabIndex        =   12
      Top             =   840
      Width           =   1215
   End
   Begin VB.Label Label4 
      Caption         =   "Step"
      Height          =   495
      Left            =   6600
      TabIndex        =   11
      Top             =   1440
      Width           =   1215
   End
   Begin VB.Label Label3 
      Caption         =   "Step"
      Height          =   495
      Left            =   240
      TabIndex        =   6
      Top             =   1440
      Width           =   1215
   End
   Begin VB.Label Label2 
      Caption         =   "Stop"
      Height          =   375
      Left            =   240
      TabIndex        =   5
      Top             =   840
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "Start"
      Height          =   375
      Left            =   240
      TabIndex        =   4
      Top             =   360
      Width           =   1215
   End
End
Attribute VB_Name = "setupfrm3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Option Base 1

Private Sub Command1_Click()
Call Testing
End Sub
'Function SetupFrm3_onSubmit()
Function Testing()
Dim ANAmin As Double
Dim ANAmax As Double

        'AgM 10-07-2002
        ANAmin = CDbl(0.045)
        ANAmax = CDbl(26.5)

Dim dblFreqs() As Double
Dim i As Integer

ReDim dblFreqs(3, 1)
    If Not (IsNumeric(fsta1)) Or Not (IsNumeric(fsto1)) Or Not (IsNumeric(fste1)) Then
    
    '            SetupFrm3_onSubmit = False
    '            alert "You must enter numeric values"
        MsgBox "You must enter numeric values"
        Exit Function
    End If
        dblFreqs(1, 1) = setupfrm3.fsta1.Text
        dblFreqs(2, 1) = setupfrm3.fsto1.Text
        dblFreqs(3, 1) = setupfrm3.fste1.Text

If CInt(setupfrm3.cboFreq.Text) > 1 Then
    If Not (IsNumeric(fsta2)) Or Not (IsNumeric(fsto2)) Or Not (IsNumeric(fste2)) Then
    
    '            SetupFrm3_onSubmit = False
    '            alert "You must enter numeric values"
        MsgBox "You must enter numeric values"
        Exit Function
    End If
    ReDim Preserve dblFreqs(3, 2)
        dblFreqs(1, 2) = setupfrm3.fsta2.Text
        dblFreqs(2, 2) = setupfrm3.fsto2.Text
        dblFreqs(3, 2) = setupfrm3.fste2.Text

End If
If CInt(setupfrm3.cboFreq.Text) > 2 Then
    If Not (IsNumeric(fsta3)) Or Not (IsNumeric(fsto3)) Or Not (IsNumeric(fste3)) Then
    
    '            SetupFrm3_onSubmit = False
    '            alert "You must enter numeric values"
        MsgBox "You must enter numeric values"
        Exit Function
    End If
    ReDim Preserve dblFreqs(3, 3)
        dblFreqs(1, 3) = setupfrm3.fsta3.Text
        dblFreqs(2, 3) = setupfrm3.fsto3.Text
        dblFreqs(3, 3) = setupfrm3.fste3.Text

End If

        
Dim fstart As Double
Dim fstop As Double
Dim fstep As Double
        
        
Dim stafreq As Double
Dim stofreq As Double

        stafreq = CDbl(0.04)
        stofreq = CDbl(18)

        If dblFreqs(1, 1) < stafreq Or dblFreqs(1, 1) > stofreq Then
'            SetupFrm3_onSubmit = False
'            alert "You have entered an invalid start frequency of " + fsta + " GHz"
            MsgBox "You have entered an invalid start frequency of " + fsta1 + " GHz"
            setupfrm3.fsta1.Text = stafreq
            Exit Function
        ElseIf dblFreqs(2, 1) < stafreq Or dblFreqs(2, 1) > stofreq Then
'            SetupFrm3_onSubmit = False
'            alert "You have entered an invalid stop frequency of " + fsto + " GHz"
            MsgBox "You have entered an invalid stop frequency of " + fsto1 + " GHz"
            setupfrm3.fsto1.Text = stofreq
            Exit Function
        ElseIf dblFreqs(2, 1) < dblFreqs(1, 1) Then
'            SetupFrm3_onSubmit = False
'            alert "You have entered an invalid frequency range"
            MsgBox "You have entered an invalid frequency range"
            setupfrm3.fsta1.Text = stafreq
            setupfrm3.fsto1.Text = stofreq
            Exit Function

        End If

        'Check frequencies dont conflict with ANA range AgM 10-07-2002

        If dblFreqs(1, 1) < ANAmin Or dblFreqs(1, 1) > ANAmax Then
'            SetupFrm3_onSubmit = False
'            alert "You have entered a start frequency outside the range of the ANA"
            MsgBox "You have entered a start frequency outside the range of the ANA"
            setupfrm3.fsta1.Text = stafreq
            Exit Function
        ElseIf dblFreqs(2, 1) > ANAmax Or dblFreqs(2, 1) < ANAmin Then
'            SetupFrm3_onSubmit = False
'            alert "You have entered a stop frequency outside the range of the ANA"
            MsgBox "You have entered a stop frequency outside the range of the ANA"
            setupfrm3.fsto1.Text = stofreq
            Exit Function

        End If

        'Check for valid step intervals

        If dblFreqs(1, 1) = dblFreqs(2, 1) And dblFreqs(3, 1) <> 0 Then
'            alert "Start and Stop frequencies identical" + Chr(13) + Chr(10) + "Step size set to 0.0 GHz, please check."
            MsgBox "Start and Stop frequencies identical" + Chr(13) + Chr(10) + "Step size set to 0.0 GHz, please check."
            setupfrm3.fste1.Text = 0#
'            SetupFrm3_onSubmit = False
            Exit Function
        ElseIf dblFreqs(1, 1) <> dblFreqs(2, 1) And dblFreqs(3, 1) = 0 Then
'            alert "You have entered an invalid step size."
            MsgBox "You have entered an invalid step size."
            setupfrm3.fste1.Text = "##.##"
'            SetupFrm3_onSubmit = False
            Exit Function
        ElseIf dblFreqs(1, 1) = dblFreqs(2, 1) And dblFreqs(3, 1) = 0 Then
'            SetupFrm3_onSubmit = True
            Exit Function
        End If
        
Dim newstop As Double
        newstop = CDbl(CStr(CInt((dblFreqs(2, 1) - dblFreqs(1, 1)) / dblFreqs(3, 1)) * dblFreqs(3, 1) + dblFreqs(1, 1)))
        If newstop <> dblFreqs(2, 1) Then
            setupfrm3.fsto1.Text = newstop
'            alert "Step size did not divide frequency range equally." + Chr(13) + Chr(10) + "Stop frequency changed, please check"
            MsgBox "Step size did not divide frequency range equally." + Chr(13) + Chr(10) + "Stop frequency changed, please check"
'            SetupFrm3_onSubmit = False
            Exit Function
        End If
        
        
        
'Frequency 2
         If dblFreqs(1, 2) < stafreq Or dblFreqs(1, 2) > stofreq Then
'            SetupFrm3_onSubmit = False
'            alert "You have entered an invalid start frequency of " + fsta + " GHz"
            MsgBox "You have entered an invalid start frequency of " + fsta1 + " GHz"
            setupfrm3.fsta2.Text = stafreq
            Exit Function
        ElseIf dblFreqs(2, 2) < stafreq Or dblFreqs(2, 2) > stofreq Then
'            SetupFrm3_onSubmit = False
'            alert "You have entered an invalid stop frequency of " + fsto + " GHz"
            MsgBox "You have entered an invalid stop frequency of " + fsto1 + " GHz"
            setupfrm3.fsto2.Text = stofreq
            Exit Function
        ElseIf dblFreqs(2, 2) < dblFreqs(1, 2) Then
'            SetupFrm3_onSubmit = False
'            alert "You have entered an invalid frequency range"
            MsgBox "You have entered an invalid frequency range"
            setupfrm3.fsta2.Text = stafreq
            setupfrm3.fsto2.Text = stofreq
            Exit Function

        End If

        'Check frequencies dont conflict with ANA range AgM 10-07-2002

        If dblFreqs(1, 2) < ANAmin Or dblFreqs(1, 2) > ANAmax Then
'            SetupFrm3_onSubmit = False
'            alert "You have entered a start frequency outside the range of the ANA"
            MsgBox "You have entered a start frequency outside the range of the ANA"
            setupfrm3.fsta2.Text = stafreq
            Exit Function
        ElseIf dblFreqs(2, 2) > ANAmax Or dblFreqs(2, 2) < ANAmin Then
'            SetupFrm3_onSubmit = False
'            alert "You have entered a stop frequency outside the range of the ANA"
            MsgBox "You have entered a stop frequency outside the range of the ANA"
            setupfrm3.fsto2.Text = stofreq
            Exit Function

        End If

        'Check for valid step intervals

        If dblFreqs(1, 2) = dblFreqs(2, 2) And dblFreqs(3, 2) <> 0 Then
'            alert "Start and Stop frequencies identical" + Chr(13) + Chr(10) + "Step size set to 0.0 GHz, please check."
            MsgBox "Start and Stop frequencies identical" + Chr(13) + Chr(10) + "Step size set to 0.0 GHz, please check."
            setupfrm3.fste2.Text = 0#
'            SetupFrm3_onSubmit = False
            Exit Function
        ElseIf dblFreqs(1, 2) <> dblFreqs(2, 2) And dblFreqs(3, 2) = 0 Then
'            alert "You have entered an invalid step size."
            MsgBox "You have entered an invalid step size."
            setupfrm3.fste2.Text = "##.##"
'            SetupFrm3_onSubmit = False
            Exit Function
        ElseIf dblFreqs(1, 2) = dblFreqs(2, 2) And dblFreqs(3, 2) = 0 Then
'            SetupFrm3_onSubmit = True
            Exit Function
        End If
        
'Dim newstop As Double
        newstop = CDbl(CStr(CInt((dblFreqs(2, 2) - dblFreqs(1, 2)) / dblFreqs(3, 2)) * dblFreqs(3, 2) + dblFreqs(1, 2)))
        If newstop <> dblFreqs(2, 2) Then
            setupfrm3.fsto2.Text = newstop
'            alert "Step size did not divide frequency range equally." + Chr(13) + Chr(10) + "Stop frequency changed, please check"
            MsgBox "Step size did not divide frequency range equally." + Chr(13) + Chr(10) + "Stop frequency changed, please check"
'            SetupFrm3_onSubmit = False
            Exit Function
        End If
        
        
        
'Frequency 3
         If dblFreqs(1, 3) < stafreq Or dblFreqs(1, 3) > stofreq Then
'            SetupFrm3_onSubmit = False
'            alert "You have entered an invalid start frequency of " + fsta + " GHz"
            MsgBox "You have entered an invalid start frequency of " + fsta1 + " GHz"
            setupfrm3.fsta3.Text = stafreq
            Exit Function
        ElseIf dblFreqs(2, 3) < stafreq Or dblFreqs(2, 3) > stofreq Then
'            SetupFrm3_onSubmit = False
'            alert "You have entered an invalid stop frequency of " + fsto + " GHz"
            MsgBox "You have entered an invalid stop frequency of " + fsto1 + " GHz"
            setupfrm3.fsto3.Text = stofreq
            Exit Function
        ElseIf dblFreqs(2, 3) < dblFreqs(1, 3) Then
'            SetupFrm3_onSubmit = False
'            alert "You have entered an invalid frequency range"
            MsgBox "You have entered an invalid frequency range"
            setupfrm3.fsta3.Text = stafreq
            setupfrm3.fsto3.Text = stofreq
            Exit Function

        End If

        'Check frequencies dont conflict with ANA range AgM 10-07-2002

        If dblFreqs(1, 3) < ANAmin Or dblFreqs(1, 3) > ANAmax Then
'            SetupFrm3_onSubmit = False
'            alert "You have entered a start frequency outside the range of the ANA"
            MsgBox "You have entered a start frequency outside the range of the ANA"
            setupfrm3.fsta3.Text = stafreq
            Exit Function
        ElseIf dblFreqs(2, 3) > ANAmax Or dblFreqs(2, 3) < ANAmin Then
'            SetupFrm3_onSubmit = False
'            alert "You have entered a stop frequency outside the range of the ANA"
            MsgBox "You have entered a stop frequency outside the range of the ANA"
            setupfrm3.fsto3.Text = stofreq
            Exit Function

        End If

        'Check for valid step intervals

        If dblFreqs(1, 3) = dblFreqs(2, 3) And dblFreqs(3, 3) <> 0 Then
'            alert "Start and Stop frequencies identical" + Chr(13) + Chr(10) + "Step size set to 0.0 GHz, please check."
            MsgBox "Start and Stop frequencies identical" + Chr(13) + Chr(10) + "Step size set to 0.0 GHz, please check."
            setupfrm3.fste3.Text = 0#
'            SetupFrm3_onSubmit = False
            Exit Function
        ElseIf dblFreqs(1, 3) <> dblFreqs(2, 3) And dblFreqs(3, 3) = 0 Then
'            alert "You have entered an invalid step size."
            MsgBox "You have entered an invalid step size."
            setupfrm3.fste3.Text = "##.##"
'            SetupFrm3_onSubmit = False
            Exit Function
        ElseIf dblFreqs(1, 3) = dblFreqs(2, 3) And dblFreqs(3, 3) = 0 Then
'            SetupFrm3_onSubmit = True
            Exit Function
        End If
        
'Dim newstop As Double
        newstop = CDbl(CStr(CInt((dblFreqs(2, 3) - dblFreqs(1, 3)) / dblFreqs(3, 3)) * dblFreqs(3, 3) + dblFreqs(1, 3)))
        If newstop <> dblFreqs(2, 3) Then
            setupfrm3.fsto3.Text = newstop
'            alert "Step size did not divide frequency range equally." + Chr(13) + Chr(10) + "Stop frequency changed, please check"
            MsgBox "Step size did not divide frequency range equally." + Chr(13) + Chr(10) + "Stop frequency changed, please check"
'            SetupFrm3_onSubmit = False
            Exit Function
        End If
        
        
        
        
        
Dim np As Double
Dim npts As Integer


        np = ((dblFreqs(2, 1) - dblFreqs(1, 1)) / dblFreqs(3, 1)) + ((dblFreqs(2, 2) - dblFreqs(1, 2)) / dblFreqs(3, 2)) + ((dblFreqs(2, 3) - dblFreqs(1, 3)) / dblFreqs(3, 3))
        npts = CInt(np)

        If npts > 500 Then
'            alert "Step size is too small." + vbCrLf + "Only 500 frequency points permitted in this version."
            MsgBox "Too many points." + vbCrLf + "Only 500 frequency points permitted in this version."
            setupfrm3.fste1.Text = "##.##"
            setupfrm3.fste2.Text = "##.##"
            setupfrm3.fste3.Text = "##.##"
'            SetupFrm3_onSubmit = False
            Exit Function
        End If

End Function
