home *** CD-ROM | disk | FTP | other *** search
Wrap
Option Strict Off Option Explicit On Imports VB = Microsoft.VisualBasic Friend Class VBShellDlg Inherits System.Windows.Forms.Form #Region "Windows Form Designer generated code " Public Sub New() MyBase.New() If m_vb6FormDefInstance Is Nothing Then If m_InitializingDefInstance Then m_vb6FormDefInstance = Me Else Try 'For the start-up form, the first instance created is the default instance. If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then m_vb6FormDefInstance = Me End If Catch End Try End If End If 'This call is required by the Windows Form Designer. InitializeComponent() End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean) If Disposing Then If Not components Is Nothing Then components.Dispose() End If End If MyBase.Dispose(Disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer Public ToolTip1 As System.Windows.Forms.ToolTip Public WithEvents chkResetNetwork As System.Windows.Forms.CheckBox Public WithEvents cmdTrainNetwork As System.Windows.Forms.Button Public WithEvents cmdClose As System.Windows.Forms.Button Public WithEvents cmdGetNetworkOutput As System.Windows.Forms.Button Public WithEvents txtTrainNetwork As System.Windows.Forms.TextBox Public WithEvents Frame1 As System.Windows.Forms.GroupBox Public WithEvents txtNetworkOutput As System.Windows.Forms.TextBox Public WithEvents Frame2 As System.Windows.Forms.GroupBox Public WithEvents Label1 As System.Windows.Forms.Label 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(VBShellDlg)) Me.components = New System.ComponentModel.Container() Me.ToolTip1 = New System.Windows.Forms.ToolTip(components) Me.ToolTip1.Active = True Me.chkResetNetwork = New System.Windows.Forms.CheckBox Me.cmdTrainNetwork = New System.Windows.Forms.Button Me.cmdClose = New System.Windows.Forms.Button Me.cmdGetNetworkOutput = New System.Windows.Forms.Button Me.Frame1 = New System.Windows.Forms.GroupBox Me.txtTrainNetwork = New System.Windows.Forms.TextBox Me.Frame2 = New System.Windows.Forms.GroupBox Me.txtNetworkOutput = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.StartPosition = System.Windows.Forms.FormStartPosition.Manual Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog Me.Text = "Custom Solution Wizard Sample" Me.ClientSize = New System.Drawing.Size(332, 325) Me.Location = New System.Drawing.Point(184, 250) Me.MaximizeBox = False Me.MinimizeBox = False Me.ShowInTaskbar = False Me.Font = New System.Drawing.Font("Arial", 8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.SystemColors.Control Me.ControlBox = True Me.Enabled = True Me.KeyPreview = False Me.Cursor = System.Windows.Forms.Cursors.Default Me.RightToLeft = System.Windows.Forms.RightToLeft.No Me.HelpButton = False Me.WindowState = System.Windows.Forms.FormWindowState.Normal Me.Name = "VBShellDlg" Me.chkResetNetwork.Text = "Reset Network Before Training" Me.chkResetNetwork.Size = New System.Drawing.Size(177, 17) Me.chkResetNetwork.Location = New System.Drawing.Point(32, 64) Me.chkResetNetwork.TabIndex = 4 Me.chkResetNetwork.Font = New System.Drawing.Font("Arial", 8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.chkResetNetwork.CheckAlign = System.Drawing.ContentAlignment.MiddleLeft Me.chkResetNetwork.BackColor = System.Drawing.SystemColors.Control Me.chkResetNetwork.CausesValidation = True Me.chkResetNetwork.Enabled = True Me.chkResetNetwork.ForeColor = System.Drawing.SystemColors.ControlText Me.chkResetNetwork.Cursor = System.Windows.Forms.Cursors.Default Me.chkResetNetwork.RightToLeft = System.Windows.Forms.RightToLeft.No Me.chkResetNetwork.Appearance = System.Windows.Forms.Appearance.Normal Me.chkResetNetwork.TabStop = True Me.chkResetNetwork.CheckState = System.Windows.Forms.CheckState.Unchecked Me.chkResetNetwork.Visible = True Me.chkResetNetwork.Name = "chkResetNetwork" Me.cmdTrainNetwork.TextAlign = System.Drawing.ContentAlignment.MiddleCenter Me.cmdTrainNetwork.Text = "Train Network" Me.cmdTrainNetwork.Size = New System.Drawing.Size(121, 25) Me.cmdTrainNetwork.Location = New System.Drawing.Point(16, 32) Me.cmdTrainNetwork.TabIndex = 2 Me.cmdTrainNetwork.Font = New System.Drawing.Font("Arial", 8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.cmdTrainNetwork.BackColor = System.Drawing.SystemColors.Control Me.cmdTrainNetwork.CausesValidation = True Me.cmdTrainNetwork.Enabled = True Me.cmdTrainNetwork.ForeColor = System.Drawing.SystemColors.ControlText Me.cmdTrainNetwork.Cursor = System.Windows.Forms.Cursors.Default Me.cmdTrainNetwork.RightToLeft = System.Windows.Forms.RightToLeft.No Me.cmdTrainNetwork.TabStop = True Me.cmdTrainNetwork.Name = "cmdTrainNetwork" Me.cmdClose.TextAlign = System.Drawing.ContentAlignment.MiddleCenter Me.cmdClose.Text = "Close" Me.cmdClose.Size = New System.Drawing.Size(81, 25) Me.cmdClose.Location = New System.Drawing.Point(128, 288) Me.cmdClose.TabIndex = 1 Me.cmdClose.Font = New System.Drawing.Font("Arial", 8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.cmdClose.BackColor = System.Drawing.SystemColors.Control Me.cmdClose.CausesValidation = True Me.cmdClose.Enabled = True Me.cmdClose.ForeColor = System.Drawing.SystemColors.ControlText Me.cmdClose.Cursor = System.Windows.Forms.Cursors.Default Me.cmdClose.RightToLeft = System.Windows.Forms.RightToLeft.No Me.cmdClose.TabStop = True Me.cmdClose.Name = "cmdClose" Me.cmdGetNetworkOutput.TextAlign = System.Drawing.ContentAlignment.MiddleCenter Me.cmdGetNetworkOutput.Text = "Get Network Output" Me.cmdGetNetworkOutput.Size = New System.Drawing.Size(121, 25) Me.cmdGetNetworkOutput.Location = New System.Drawing.Point(16, 96) Me.cmdGetNetworkOutput.TabIndex = 0 Me.cmdGetNetworkOutput.Font = New System.Drawing.Font("Arial", 8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.cmdGetNetworkOutput.BackColor = System.Drawing.SystemColors.Control Me.cmdGetNetworkOutput.CausesValidation = True Me.cmdGetNetworkOutput.Enabled = True Me.cmdGetNetworkOutput.ForeColor = System.Drawing.SystemColors.ControlText Me.cmdGetNetworkOutput.Cursor = System.Windows.Forms.Cursors.Default Me.cmdGetNetworkOutput.RightToLeft = System.Windows.Forms.RightToLeft.No Me.cmdGetNetworkOutput.TabStop = True Me.cmdGetNetworkOutput.Name = "cmdGetNetworkOutput" Me.Frame1.Text = "Press the buttons to run the sample functions" Me.Frame1.Size = New System.Drawing.Size(313, 81) Me.Frame1.Location = New System.Drawing.Point(8, 8) Me.Frame1.TabIndex = 5 Me.Frame1.Font = New System.Drawing.Font("Arial", 8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Frame1.BackColor = System.Drawing.SystemColors.Control Me.Frame1.Enabled = True Me.Frame1.ForeColor = System.Drawing.SystemColors.ControlText Me.Frame1.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Frame1.Visible = True Me.Frame1.Name = "Frame1" Me.txtTrainNetwork.AutoSize = False Me.txtTrainNetwork.Size = New System.Drawing.Size(161, 25) Me.txtTrainNetwork.Location = New System.Drawing.Point(144, 24) Me.txtTrainNetwork.ReadOnly = True Me.txtTrainNetwork.TabIndex = 6 Me.txtTrainNetwork.Text = "Not Tested." Me.txtTrainNetwork.Font = New System.Drawing.Font("Arial", 8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtTrainNetwork.AcceptsReturn = True Me.txtTrainNetwork.TextAlign = System.Windows.Forms.HorizontalAlignment.Left Me.txtTrainNetwork.BackColor = System.Drawing.SystemColors.Window Me.txtTrainNetwork.CausesValidation = True Me.txtTrainNetwork.Enabled = True Me.txtTrainNetwork.ForeColor = System.Drawing.SystemColors.WindowText Me.txtTrainNetwork.HideSelection = True Me.txtTrainNetwork.Maxlength = 0 Me.txtTrainNetwork.Cursor = System.Windows.Forms.Cursors.IBeam Me.txtTrainNetwork.MultiLine = False Me.txtTrainNetwork.RightToLeft = System.Windows.Forms.RightToLeft.No Me.txtTrainNetwork.ScrollBars = System.Windows.Forms.ScrollBars.None Me.txtTrainNetwork.TabStop = True Me.txtTrainNetwork.Visible = True Me.txtTrainNetwork.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.txtTrainNetwork.Name = "txtTrainNetwork" Me.Frame2.Size = New System.Drawing.Size(313, 161) Me.Frame2.Location = New System.Drawing.Point(8, 80) Me.Frame2.TabIndex = 7 Me.Frame2.Font = New System.Drawing.Font("Arial", 8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Frame2.BackColor = System.Drawing.SystemColors.Control Me.Frame2.Enabled = True Me.Frame2.ForeColor = System.Drawing.SystemColors.ControlText Me.Frame2.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Frame2.Visible = True Me.Frame2.Name = "Frame2" Me.txtNetworkOutput.AutoSize = False Me.txtNetworkOutput.Font = New System.Drawing.Font("Courier New", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtNetworkOutput.Size = New System.Drawing.Size(297, 105) Me.txtNetworkOutput.Location = New System.Drawing.Point(8, 48) Me.txtNetworkOutput.ReadOnly = True Me.txtNetworkOutput.MultiLine = True Me.txtNetworkOutput.ScrollBars = System.Windows.Forms.ScrollBars.Both Me.txtNetworkOutput.WordWrap = False Me.txtNetworkOutput.TabIndex = 8 Me.txtNetworkOutput.Text = "Not Tested." & Chr(13) & Chr(10) Me.txtNetworkOutput.AcceptsReturn = True Me.txtNetworkOutput.TextAlign = System.Windows.Forms.HorizontalAlignment.Left Me.txtNetworkOutput.BackColor = System.Drawing.SystemColors.Window Me.txtNetworkOutput.CausesValidation = True Me.txtNetworkOutput.Enabled = True Me.txtNetworkOutput.ForeColor = System.Drawing.SystemColors.WindowText Me.txtNetworkOutput.HideSelection = True Me.txtNetworkOutput.Maxlength = 0 Me.txtNetworkOutput.Cursor = System.Windows.Forms.Cursors.IBeam Me.txtNetworkOutput.RightToLeft = System.Windows.Forms.RightToLeft.No Me.txtNetworkOutput.TabStop = True Me.txtNetworkOutput.Visible = True Me.txtNetworkOutput.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.txtNetworkOutput.Name = "txtNetworkOutput" Me.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter Me.Label1.Text = "The sample functions associated with these buttons have been modified to work with your training data." Me.Label1.Size = New System.Drawing.Size(273, 33) Me.Label1.Location = New System.Drawing.Point(32, 248) Me.Label1.TabIndex = 3 Me.Label1.Font = New System.Drawing.Font("Arial", 8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.BackColor = System.Drawing.SystemColors.Control Me.Label1.Enabled = True Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText Me.Label1.Cursor = System.Windows.Forms.Cursors.Default Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Label1.UseMnemonic = True Me.Label1.Visible = True Me.Label1.AutoSize = False Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label1.Name = "Label1" Me.Controls.Add(chkResetNetwork) Me.Controls.Add(cmdTrainNetwork) Me.Controls.Add(cmdClose) Me.Controls.Add(cmdGetNetworkOutput) Me.Controls.Add(Frame1) Me.Controls.Add(Frame2) Me.Controls.Add(Label1) Me.Frame1.Controls.Add(txtTrainNetwork) Me.Frame2.Controls.Add(txtNetworkOutput) End Sub #End Region #Region "Upgrade Support " Private Shared m_vb6FormDefInstance As VBShellDlg Private Shared m_InitializingDefInstance As Boolean Public Shared Property DefInstance() As VBShellDlg Get If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then m_InitializingDefInstance = True m_vb6FormDefInstance = New VBShellDlg() m_InitializingDefInstance = False End If DefInstance = m_vb6FormDefInstance End Get Set m_vb6FormDefInstance = Value End Set End Property #End Region Private Sub cmdClose_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdClose.Click Me.Close() End Sub Private Sub VBShellDlg_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load resetNetwork = True chkResetNetwork.CheckState = System.Windows.Forms.CheckState.Checked If RECALL_ONLY_NETWORK = True Then txtTrainNetwork.Text = "Recall Network Only." cmdTrainNetwork.Enabled = False chkResetNetwork.Enabled = False Else txtTrainNetwork.Text = "Not tested." End If txtNetworkOutput.Text = "Not tested." End Sub Private Sub cmdGetNetworkOutput_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdGetNetworkOutput.Click 'Get the network response as an array of outputs Dim networkResponse As Object networkResponse = GetNetworkResponse() 'Clear contents of the list box txtNetworkOutput.Text = "" 'Get/Create the column labels for the output data Dim outputLabelsArray As Object Dim i As Integer Dim outputLabels As String If CheckIfFileOnFileSystem(DATA_PATH & "\", DESIRED_FILE_NAME) = True Then FileOpen(1, DATA_PATH & "\" & DESIRED_FILE_NAME, OpenMode.Input) outputLabels = LineInput(1) FileClose(1) outputLabelsArray = Split(outputLabels, Chr(9)) Else ReDim outputLabelsArray(UBound(networkResponse, 2)) For i = LBound(outputLabelsArray) To UBound(outputLabelsArray) outputLabelsArray(i) = "Output#" & i + 1 Next i End If Dim numberOfTrailingSpaces As Short Dim outStr As String outStr = "Exemplar#" For i = LBound(outputLabelsArray) To UBound(outputLabelsArray) numberOfTrailingSpaces = 9 - Len(outputLabelsArray(i)) If (numberOfTrailingSpaces > 0) Then outStr = outStr & Chr(9) & outputLabelsArray(i) & Space(numberOfTrailingSpaces) Else outStr = outStr & Chr(9) & VB.Left(outputLabelsArray(i), 9) End If Next i outStr = outStr & vbCrLf 'Prepare output data for display in text box. Limit to 1000 rows. Dim j As Integer Dim maxRows As Integer maxRows = IIf(UBound(networkResponse, 1) > 1000, 1000, UBound(networkResponse, 1)) For i = LBound(networkResponse, 1) To UBound(networkResponse, 1) outStr = outStr & VB6.Format(i + 1, "00000") & " " For j = LBound(networkResponse, 2) To UBound(networkResponse, 2) outStr = outStr & Chr(9) & VB6.Format(networkResponse(i, j), "0.0000000") Next j outStr = outStr & vbCrLf Next i 'Display output data in text box txtNetworkOutput.Text = outStr End Sub Private Sub chkResetNetwork_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkResetNetwork.CheckStateChanged If chkResetNetwork.CheckState = System.Windows.Forms.CheckState.Checked Then resetNetwork = True Else resetNetwork = False End If End Sub Private Sub cmdTrainNetwork_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdTrainNetwork.Click txtTrainNetwork.Text = "Training..." txtTrainNetwork.Refresh() Dim trainingBestCost As Object trainingBestCost = TrainNetwork() txtTrainNetwork.Text = "Best Cost = " & trainingBestCost End Sub Function CheckIfFileOnFileSystem(ByRef filePath As String, ByRef fileName As String) As Boolean 'Determine if a file with the given fileName exists in the given filePath On Error GoTo ErrorHandler Dim filePathName As String filePathName = filePath & fileName If StrComp(Dir(filePathName, FileAttribute.Normal), fileName, CompareMethod.Text) <> 0 Then CheckIfFileOnFileSystem = False Else CheckIfFileOnFileSystem = True End If On Error GoTo 0 Exit Function ErrorHandler: CheckIfFileOnFileSystem = False End Function End Class