Frequency Form Code

1

Appendix B

Frequency Form Code

'------

'Lance Nicholas Covert

'frmFrequency form (frmFrequency.frm)

'------

'This is the code for the frequency form (the form that

'plots the magnitude and phase responses after the FFT

'is performed).

'This form is displayed on pg. 61 of the Thesis

'This code should be used in conjunction with the

'list of objects and parameters for constructing

'frmFrequency.frm

'------

Option Explicit 'All variables MUST be declared

Dim NumberOfLabels As Integer

'------

'printing the picture box only

Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const WM_PAINT = &HF

Private Const WM_PRINT = &H317

Private Const PRF_CLIENT = &H4& ' Draw the window's client area

Private Const PRF_CHILDREN = &H10& ' Draw all visible child

Private Const PRF_OWNED = &H20& ' Draw all owned windows

'------

Private Sub cboExpandYaxis_FreqPlot_Click()

Call frmSamples7.cboExpandYaxis_FreqPlot_Click

End Sub

Private Sub cboExpandYaxis_FreqPlotVolts_Click()

Call frmSamples7.cboExpandYaxis_FreqPlotVolts_Click

End Sub

Private Sub chkDecibels_Click()

Call hsbFrequency_Change

End Sub

Private Sub cmdCursorShiftLeft_Click()

Call frmSamples7.cmdCursorShiftLeft_Click

End Sub

Private Sub cmdPrint_Click()

'Printer.ScaleLeft = picGraph2.Left

'Printer.ScaleTop = picGraph2.Top

'Printer.Width = picGraph2.ScaleWidth

'Printer.Height = picGraph2.ScaleHeight

'------

'use these two statements to print the form

'Note: The contents of the picture box will not be printed.

frmFrequency.PrintForm

Printer.EndDoc

'------

'------

'use this statement to print the contents of the picture box

'frmSamples7.PrintPictureBox frmFrequency.picGraph2, 1000, 1000

'PrintPictureBox frmFrequency, 1000, 1000

'------

End Sub

Private Sub cmdCursorShiftRight_Click()

Call frmSamples7.cmdCursorShiftRight_Click

End Sub

Public Sub Form_Load()

'This subroutine executes when the magnitude/frequency plot form loads.

Dim i As Integer

'number of frequency axis labels on the frmFrequency

NumberOfLabels = 10

For i = 0 To NumberOfLabels - 1

lblHz(i).Width = 500

lblHz(i).Height = 255

Next

i = 0

For i = 0 To 8

frmFrequency.lblYaxisFreq(i).Left = frmFrequency.picGraph2.Left - frmFrequency.lblYaxisFreq(i).Width

Next

i = 1

For i = i To 8

frmFrequency.lblYaxisFreqN(i).Left = frmFrequency.picGraph2.Left - frmFrequency.lblYaxisFreqN(i).Width

Next

frmFrequency.lbldegrees(0).Left = frmFrequency.picGraph3.Left - frmFrequency.lbldegrees(0).Width

For i = 1 To 4

frmFrequency.lbldegrees(i).Left = frmFrequency.picGraph3.Left - frmFrequency.lbldegrees(i).Width

Next

For i = 1 To 4

frmFrequency.lblDegreesN(i).Left = frmFrequency.picGraph3.Left - frmFrequency.lblDegreesN(i).Width

Next

'fill the cboExpandYaxis_FreqPlot combo box

cboExpandYaxis_FreqPlot.AddItem "400 dB/div"

cboExpandYaxis_FreqPlot.AddItem "200 dB/div"

cboExpandYaxis_FreqPlot.AddItem "100 dB/div"

cboExpandYaxis_FreqPlot.AddItem "80 dB/div"

cboExpandYaxis_FreqPlot.AddItem "50 dB/div"

cboExpandYaxis_FreqPlot.AddItem "40 dB/div"

cboExpandYaxis_FreqPlot.AddItem "25 dB/div"

cboExpandYaxis_FreqPlot.AddItem "20 dB/div"

cboExpandYaxis_FreqPlot.AddItem "16 dB/div"

cboExpandYaxis_FreqPlot.AddItem "10 dB/div"

cboExpandYaxis_FreqPlot.AddItem "8 dB/div"

cboExpandYaxis_FreqPlot.AddItem "5 dB/div"

'Default to 40 dB/div on initial load

cboExpandYaxis_FreqPlot.ListIndex = 5

'fill the cboExpandYaxis_FreqPlotVolts combo box

cboExpandYaxis_FreqPlotVolts.AddItem "8 V/div"

cboExpandYaxis_FreqPlotVolts.AddItem "4 V/div"

cboExpandYaxis_FreqPlotVolts.AddItem "2 V/div"

cboExpandYaxis_FreqPlotVolts.AddItem "1 V/div"

cboExpandYaxis_FreqPlotVolts.AddItem "0.8 V/div"

cboExpandYaxis_FreqPlotVolts.AddItem "0.5 V/div"

cboExpandYaxis_FreqPlotVolts.AddItem "0.4 V/div"

cboExpandYaxis_FreqPlotVolts.AddItem "0.2 V/div"

cboExpandYaxis_FreqPlotVolts.AddItem "0.1 V/div"

cboExpandYaxis_FreqPlotVolts.AddItem "0.08 V/div"

cboExpandYaxis_FreqPlotVolts.AddItem "0.05 V/div"

cboExpandYaxis_FreqPlotVolts.AddItem "0.04 V/div"

cboExpandYaxis_FreqPlotVolts.AddItem "0.02 V/div"

cboExpandYaxis_FreqPlotVolts.AddItem "0.01 V/div"

cboExpandYaxis_FreqPlotVolts.AddItem "0.005 V/div"

cboExpandYaxis_FreqPlotVolts.AddItem "0.002 V/div"

'Default to 0.5 V/div on initial load

cboExpandYaxis_FreqPlotVolts.ListIndex = 5

End Sub

Private Sub hsbScroll_FreqPlot_Change()

Call frmSamples7.hsbScroll_FreqPlot_Change

End Sub

Private Sub hsbScroll_FreqPlot_Scroll()

Call hsbScroll_FreqPlot_Change

End Sub

Private Sub vsbExpandYaxis_FreqPlot_Change()

Call frmSamples7.vsbExpandYaxis_FreqPlot_Change

End Sub

Private Sub hsbFrequency_Change()

Call frmSamples7.hsbFrequency_Change

End Sub

Private Sub hsbFrequency_Scroll()

Call frmSamples7.hsbFrequency_Change

End Sub

Private Sub mnuDCComponent_click()

Call frmSamples7.mnuDCComponent_click

End Sub

Private Sub mnuExit2_Click()

frmFrequency.Hide

End Sub

Private Sub vsbZeroAxis_FrequencyPlot_Change()

lblVsbZeroaxis.Caption = vsbZeroAxis_FrequencyPlot.Value 'for testing, just shows the value of the scroll bar

Call frmSamples7.vsbZeroAxis_FrequencyPlot_Change

End Sub

Private Sub vsbZeroAxis_FrequencyPlot_Scroll()

lblVsbZeroaxis.Caption = vsbZeroAxis_FrequencyPlot.Value 'for testing, just shows the value of the scroll bar

Call frmSamples7.vsbZeroAxis_FrequencyPlot_Change

End Sub

Private Sub picGraph2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Call frmSamples7.picGraph2_MouseDown(Button, Shift, X, Y)

End Sub

Private Sub picGraph3_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Call frmSamples7.picGraph2_MouseDown(Button, Shift, X, Y)

End Sub