📄 frmsom.frm
字号:
Caption = "W2"
Height = 255
Index = 0
Left = 6600
TabIndex = 13
Top = 1080
Width = 255
End
Begin VB.Label Label6
Alignment = 2 'Center
Caption = "W1"
Height = 255
Index = 0
Left = 10200
TabIndex = 12
Top = 4440
Width = 255
End
Begin VB.Label Label5
Alignment = 2 'Center
Caption = "X2"
Height = 255
Index = 0
Left = 240
TabIndex = 11
Top = 1080
Width = 255
End
Begin VB.Label Label4
Alignment = 2 'Center
Caption = "X1"
Height = 255
Index = 0
Left = 3720
TabIndex = 10
Top = 4440
Width = 255
End
Begin VB.Label Label3
Caption = "学习系数"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4680
TabIndex = 6
Top = 2760
Width = 855
End
Begin VB.Label Label7
Caption = "学习次数"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4680
TabIndex = 5
Top = 3720
Width = 855
End
Begin VB.Label Label2
Caption = "输入分布"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 1680
TabIndex = 1
Top = 720
Width = 1095
End
Begin VB.Label Label1
Caption = "SOM网络演示"
BeginProperty Font
Name = "宋体"
Size = 24
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3720
TabIndex = 0
Top = 240
Width = 2895
End
End
Attribute VB_Name = "FrmSOM"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim CmdMark As Integer
Private Sub Command1_Click()
Dim j As Integer
L = Val(Text3.Text)
Times = Val(Text4.Text)
Call StudyMain
Call Draw_Weight
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
Call Read_StudyMode
Call Calculate
Call Draw_Result
End Sub
Private Sub Command4_Click()
Dim i As Integer
For i = 1 To MM
Label15(i).Visible = True
Label10(i).Visible = True
Next i
For i = 1 To KK
Label16(i).Visible = True
Next i
End Sub
Private Sub Form_Load()
ReDim A(KK, NN)
ReDim W(NN, MM)
ReDim B(MM, 2)
ReDim d(MM)
ReDim AA(NN)
ReDim BB(MM)
CmdMark = 0
Call Initial
Call Draw_Input
Call Draw_Output
Call Draw_Weight
Call Pic1Redraw
Call Text1Load
AAA = Val(Text2.Text)
End Sub
Private Sub Draw_Input()
Dim i, j As Integer
Dim count As Integer
count = Int(Sqr(KK))
For i = 1 To KK / count
For j = 1 To count
Load Shape1((i - 1) * count + j)
Shape1((i - 1) * count + j).Visible = True
Shape1((i - 1) * count + j).Left = (Picture5.Width * 0.9) * A((i - 1) * count + j, 1)
Shape1((i - 1) * count + j).Top = (Picture5.Height * 0.9) * A((i - 1) * count + j, 2)
Load Label16((i - 1) * count + j)
Label16((i - 1) * count + j).Left = (Picture5.Width * 0.9) * A((i - 1) * count + j, 1)
Label16((i - 1) * count + j).Top = (Picture5.Height * 0.9) * A((i - 1) * count + j, 2)
Label16((i - 1) * count + j).Visible = False
Label16((i - 1) * count + j).Caption = (i - 1) * count + j
Next j
Next i
End Sub
Private Sub Draw_Output()
Dim i, j As Integer
Dim count As Integer
count = Int(Sqr(MM))
For i = 1 To MM / count
For j = 1 To count
Load Shape3((i - 1) * count + j)
Shape3((i - 1) * count + j).Visible = True
Shape3((i - 1) * count + j).Left = (Picture7.Width * 0.9) * B((i - 1) * count + j, 1)
Shape3((i - 1) * count + j).Top = (Picture7.Height * 0.9) * B((i - 1) * count + j, 2)
Shape3((i - 1) * count + j).Width = Shape3((i - 1) * count + j).Width + BB((i - 1) * count + j)
Shape3((i - 1) * count + j).Height = Shape3((i - 1) * count + j).Height + BB((i - 1) * count + j)
Load Label10((i - 1) * count + j)
Label10((i - 1) * count + j).Visible = False
Label10((i - 1) * count + j).Left = (Picture7.Width * 0.9) * B((i - 1) * count + j, 1)
Label10((i - 1) * count + j).Top = (Picture7.Height * 0.9) * B((i - 1) * count + j, 2)
Label10((i - 1) * count + j).Width = Label10((i - 1) * count + j).Width + BB((i - 1) * count + j)
Label10((i - 1) * count + j).Height = Label10((i - 1) * count + j).Height + BB((i - 1) * count + j)
Label10((i - 1) * count + j).Caption = (i - 1) * count + j
Next j
Next i
Picture7.Width = Picture7.Width + Shape3(0).Width
Picture7.Height = Picture7.Height + Shape3(0).Height
End Sub
Private Sub Draw_Result()
Dim i, j As Integer
Dim count As Integer
count = Int(Sqr(MM))
For i = 1 To MM / count
For j = 1 To count
Shape3((i - 1) * count + j).Width = Shape3(0).Width * (1 + 0.1 / BB((i - 1) * count + j))
Shape3((i - 1) * count + j).Height = Shape3(0).Height * (1 + 0.1 / BB((i - 1) * count + j))
Next j
Next i
Shape4.Visible = True
Shape4.Left = (Picture5.Width * 0.9) * AA(1)
Shape4.Top = (Picture5.Height * 0.9) * AA(2)
End Sub
Private Sub Draw_Weight()
Dim i, j As Integer
Dim count As Integer
count = Int(Sqr(KK))
For i = 1 To MM
If CmdMark <> 1 Then
Load Shape2(i)
Load Label15(i)
End If
Shape2(i).Visible = True
Label15(i).Caption = i
Shape2(i).Left = (Picture6.Width * 0.9) * W(1, i)
Shape2(i).Top = (Picture6.Height * 0.9) * W(2, i)
Label15(i).Visible = False
Label15(i).Left = (Picture6.Width * 0.9) * W(1, i)
Label15(i).Top = (Picture6.Height * 0.9) * W(2, i)
Label10(i).Visible = False
Next i
For i = 1 To KK
Label16(i).Visible = False
Next i
CmdMark = 1
End Sub
Private Sub Read_StudyMode()
Dim i, j As Integer
For i = 0 To 1 - 1 '水平表格中的各个文本框
For j = 1 To NN '垂直表格中的各个文本框
AA(j) = Val(Text1(i * NN + j).Text)
Next j
Next i
End Sub
Private Sub Text2_LostFocus()
AAA = Val(Text2.Text)
End Sub
Private Sub Pic1Redraw() '视窗图片重绘子程序
'设置表格载体图片控件的属性
Picture2.Width = NN * Text1(0).Width + 50
Picture2.Height = 1 * Text1(0).Height + 50
'判断滚动条出现的不同情况
If Picture1.Width < Picture2.Width + Picture2.Left * 2 _
And Picture1.Height < Picture2.Height + Picture2.Top * 2 Then
'水平、垂直滚动条都出现
HScroll1.Left = 0
HScroll1.Top = Picture1.Height - HScroll1.Height
HScroll1.Width = Picture1.Width
HScroll1.Max = Picture2.Width + 2 * Picture2.Left - Picture1.Width
HScroll1.Min = 0
VScroll1.Top = 0
VScroll1.Left = Picture1.Width - VScroll1.Width
VScroll1.Height = Picture1.Height - HScroll1.Height
VScroll1.Max = Picture2.Height + 2 * Picture2.Top - Picture1.Height
VScroll1.Min = 0
HScroll1.Visible = True
VScroll1.Visible = True
ElseIf Picture1.Width < Picture2.Width + Picture2.Left * 2 Then
'只出现水平滚动条
HScroll1.Left = 0
HScroll1.Top = Picture1.Height - HScroll1.Height
HScroll1.Width = Picture1.Width
HScroll1.Max = Picture2.Width + 2 * Picture2.Left - Picture1.Width
HScroll1.Min = 0
HScroll1.Visible = True
VScroll1.Visible = False
ElseIf Picture1.Height < Picture2.Height + Picture2.Top * 2 Then
'只出现垂直滚动条
VScroll1.Top = 0
VScroll1.Left = Picture1.Width - VScroll1.Width
VScroll1.Height = Picture1.Height
VScroll1.Max = Picture2.Height + 2 * Picture2.Top - Picture1.Height
VScroll1.Min = 0
HScroll1.Visible = False
VScroll1.Visible = True
Else
HScroll1.Visible = False
VScroll1.Visible = False
End If
HScroll1.SmallChange = 20
HScroll1.LargeChange = (HScroll1.Max - HScroll1.Min) / 10
HScroll1.Value = 0
VScroll1.SmallChange = 20
VScroll1.LargeChange = (VScroll1.Max - VScroll1.Min) / 10
VScroll1.Value = 0
End Sub
Private Sub HScroll1_Change() '水平滚动条变化
Picture2.Left = 0 - HScroll1.Value
End Sub
Private Sub Text1Load() '调入文本框控件
Dim i, j As Integer
For i = 0 To 1 - 1 '调入水平表格中的各个文本框
For j = 1 To NN '调入垂直表格中的各个文本框
Load Text1(i * NN + j)
Text1(i * NN + j).Visible = True
Text1(i * NN + j).Left = Text1(0).Width * (j - 1)
Text1(i * NN + j).Top = Text1(0).Height * i
Text1(i * NN + j).Text = ""
Next j
Next i
End Sub
Private Sub Text1_Change(Index As Integer)
Command1.Enabled = True
End Sub
Private Sub VScroll1_Change() '垂直滚动条
Picture2.Top = 0 - VScroll1.Value
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -