⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form9.frm

📁 是关于MATALB 神经网络与VB的混合编程,希望对大家有所帮助
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form9 
   Caption         =   "新建检验样本"
   ClientHeight    =   3450
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3855
   ControlBox      =   0   'False
   LinkTopic       =   "Form9"
   ScaleHeight     =   3450
   ScaleWidth      =   3855
   StartUpPosition =   2  'CenterScreen
   Begin VB.Frame Frame1 
      Caption         =   "请输入第1组训练样本"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2055
      Left            =   360
      TabIndex        =   2
      Top             =   480
      Width           =   3015
      Begin VB.TextBox TxtInput 
         Height          =   495
         Index           =   0
         Left            =   1320
         TabIndex        =   4
         Top             =   240
         Width           =   1455
      End
      Begin VB.TextBox TxtOutput 
         Height          =   495
         Index           =   0
         Left            =   1320
         TabIndex        =   3
         Top             =   1200
         Width           =   1455
      End
      Begin VB.Label Label1 
         Caption         =   "输入值1:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   0
         Left            =   240
         TabIndex        =   6
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "输出值1:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   0
         Left            =   240
         TabIndex        =   5
         Top             =   1320
         Width           =   975
      End
   End
   Begin VB.CommandButton Command1 
      Caption         =   "输入"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   600
      TabIndex        =   1
      Top             =   2640
      Width           =   1095
   End
   Begin VB.CommandButton Command2 
      Caption         =   "完成"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   2040
      TabIndex        =   0
      Top             =   2640
      Width           =   1095
   End
End
Attribute VB_Name = "Form9"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()

    Dim i As Integer
    For i = 0 To LayerNodes(1) - 1
        If TxtInput(i).Text = "" Then
            MsgBox "请输入第" & LTrim(Str(i + 1)) & "个输入值", vbExclamation, "!!!"
            Exit Sub
        End If
    Next i
    For i = 0 To LayerNodes(LayerNum) - 1
        If TxtOutput(i).Text = "" Then
            MsgBox "请输入第" & LTrim(Str(i + 1)) & "个输出值", vbExclamation, "!!!"
            Exit Sub
        End If
    Next i
    ReDim Preserve dbTI(LayerNodes(1), TSample_num)
    ReDim Preserve dbTO(LayerNodes(LayerNum), TSample_num)
    
    For i = 0 To LayerNodes(1) - 1
        If Val(TxtInput(i)) > InMax(i + 1) Or Val(TxtInput(i)) < InMin(i + 1) Then
            MsgBox "第" & LTrim(Str(i + 1)) & "输入值应在" & LTrim(Str(InMin(i + 1))) & "和" & LTrim(Str(InMax(i + 1))) & "之间", vbExclamation, "!!!"
            Exit Sub
        End If
    Next i
    For i = 0 To LayerNodes(LayerNum) - 1
        If Val(TxtOutput(i)) > OutMax(i + 1) Or Val(TxtOutput(i)) < OutMin(i + 1) Then
            MsgBox "第" & LTrim(Str(i + 1)) & "个期望输出有误!", vbExclamation, "!!!"
            Exit Sub
        End If
    Next i
    
    For i = 0 To LayerNodes(1) - 1
        dbTI(i + 1, TSample_num) = Val(TxtInput(i).Text)
        'Form1.Sample.AddItem "dbI(" & LTrim(Str(i + 1)) & "," & LTrim(Sample_num) & ")=" & LTrim(Str(dbI(i + 1, Sample_num)))
        TxtInput(i).Text = ""
    Next i
    For i = 0 To LayerNodes(LayerNum) - 1
        dbTO(i + 1, TSample_num) = Val(TxtOutput(i).Text)
        'Form1.Sample.AddItem "dbO(" & LTrim(Str(i + 1)) & "," & LTrim(Sample_num) & ")=" & LTrim(Str(dbI(i + 1, Sample_num)))
        TxtOutput(i).Text = ""
    Next i
    
    TSample_num = TSample_num + 1
    Frame1.Caption = "请输入第" & LTrim(Str(TSample_num)) & "组检验样本"
    
End Sub

Private Sub Command2_Click()

    Dim i As Integer
    TSample_num = TSample_num - 1
    Unload Form9
    Form1.Show
    
End Sub

Private Sub Form_Activate()

    Dim i As Integer
    If LayerNum < 1 Then
        MsgBox "请先选择样本", vbExclamation, "!!!"
        Form1.Show
        Exit Sub
    End If
    
    TSample_num = 1
    
    For i = 1 To LayerNodes(1) - 1
        Load TxtInput(i)
        Load Label1(i)
        TxtInput(i).Top = TxtInput(i - 1).Top + TxtInput(i - 1).Height + 150
        TxtInput(i).Left = TxtInput(i - 1).Left
        TxtInput(i).Visible = True
        Label1(i).Top = TxtInput(i).Top + 120
        Label1(i).Left = Label1(i - 1).Left
        Label1(i).Visible = True
        Label1(i).Caption = "输入值" & Str(i + 1) & ":"
    Next i
    TxtOutput(0).Top = TxtInput(LayerNodes(1) - 1).Top + TxtInput(LayerNodes(1) - 1).Height + 150
    TxtOutput(0).Left = TxtInput(LayerNodes(1) - 1).Left
    Label2(0).Top = TxtOutput(0).Top + 120
    Label2(0).Left = Label1(LayerNodes(1) - 1).Left
    For i = 1 To LayerNodes(LayerNum) - 1
        Load TxtOutput(i)
        Load Label2(i)
        TxtOutput(i).Top = TxtOutput(i - 1).Top + TxtOutput(i - 1).Height + 150
        TxtOutput(i).Left = TxtOutput(i - 1).Left
        TxtOutput(i).Visible = True
        Label2(i).Top = TxtOutput(i).Top + 120
        Label2(i).Left = Label1(i - 1).Left
        Label2(i).Caption = "输出值" & Str(i + 1) & ":"
        Label2(i).Visible = True
    Next i
    Frame1.Height = TxtOutput(LayerNodes(LayerNum) - 1).Top _
        + TxtOutput(LayerNodes(LayerNum) - 1).Height + 200
    Command1.Left = Frame1.Left + 100
    Command1.Top = Frame1.Top + Frame1.Height + 300
    Command2.Left = Frame1.Left + Frame1.Width - 100 - Command2.Width
    Command2.Top = Command1.Top
    Form9.Height = Command2.Top + Command2.Height + 550
End Sub
Private Sub TxtInput_KeyPress(Index As Integer, KeyAscii As Integer)

    Dim i As Integer, n As Integer
    Dim TrainFX
    Set TrainFX = New FunctionDLL.TrainF
    n = TrainFX.GetNum(LayerNodes(1))
    If Index = LayerNodes(1) - 1 And KeyAscii = 13 Then
        For i = 0 To LayerNodes(LayerNum) - 1
            If TFunctionNum(i + 1) <> -1 Then
                Select Case LayerNodes(1)
                    Case 1
                        TxtOutput(i) = TrainFX.dbOne(TFunctionNum(i + 1), Val(TxtInput(0)))
                    Case 2
                        TxtOutput(i) = TrainFX.dbTwo(TFunctionNum(i + 1), Val(TxtInput(0)), Val(TxtInput(1)))
                    Case 3
                        TxtOutput(i) = TrainFX.dbThree(TFunctionNum(i + 1), Val(TxtInput(0)), Val(TxtInput(1)), Val(TxtInput(2)))
                    Case 4
                        TxtOutput(i) = TrainFX.dbFour(TFunctionNum(i + 1), Val(TxtInput(0)), Val(TxtInput(1)), Val(TxtInput(2)), Val(TxtInput(3)))
                End Select
            End If
        Next i
    End If

End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -