📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 8235
ClientLeft = 60
ClientTop = 450
ClientWidth = 14265
LinkTopic = "Form1"
ScaleHeight = 8235
ScaleWidth = 14265
StartUpPosition = 1 '所有者中心
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 200
Left = 5760
Top = 120
End
Begin VB.CheckBox Check1
Caption = "实时生成"
Height = 495
Left = 4680
TabIndex = 13
Top = 120
Width = 1215
End
Begin VB.Frame Frame2
Caption = "图 形"
Height = 6735
Left = 6480
TabIndex = 11
Top = 840
Width = 6975
Begin VB.PictureBox Picture1
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000004&
BorderStyle = 0 'None
ForeColor = &H80000008&
Height = 600
Index = 0
Left = 0
Picture = "Form1.frx":0000
ScaleHeight = 600
ScaleWidth = 600
TabIndex = 12
Top = 620
Width = 600
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "节点"
Height = 180
Left = 120
TabIndex = 16
Top = 360
Width = 360
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "Row1"
Height = 180
Index = 0
Left = 120
TabIndex = 15
Top = 360
Width = 360
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "Label6"
Height = 180
Index = 0
Left = 80
TabIndex = 14
Top = 360
Visible = 0 'False
Width = 540
End
Begin VB.Line Line4
X1 = 120
X2 = 6720
Y1 = 600
Y2 = 600
End
Begin VB.Line Line3
X1 = 585
X2 = 585
Y1 = 240
Y2 = 6600
End
End
Begin VB.TextBox Text3
Height = 270
Left = 1320
TabIndex = 9
Text = "10"
Top = 240
Width = 495
End
Begin VB.CommandButton Command2
Caption = "绘制"
Height = 375
Left = 3600
TabIndex = 7
Top = 200
Width = 975
End
Begin VB.TextBox Text2
Height = 270
Left = 360
TabIndex = 2
Text = "10"
Top = 240
Width = 495
End
Begin VB.CommandButton Command1
Caption = "输入"
Height = 375
Left = 2280
TabIndex = 1
Top = 200
Width = 1095
End
Begin VB.Frame Frame1
Caption = "矩 阵"
Height = 6735
Left = 120
TabIndex = 0
Top = 840
Width = 6255
Begin VB.TextBox Text1
Height = 270
Index = 0
Left = 120
TabIndex = 6
Text = "Text1"
Top = 840
Width = 375
End
Begin VB.Label Label3
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "V1"
Height = 180
Index = 0
Left = 360
TabIndex = 5
Top = 360
Visible = 0 'False
Width = 180
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "V1"
Height = 180
Index = 0
Left = 240
TabIndex = 4
Top = 360
Visible = 0 'False
Width = 180
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "节点"
Height = 180
Left = 120
TabIndex = 3
Top = 360
Width = 360
End
Begin VB.Line Line2
X1 = 600
X2 = 600
Y1 = 360
Y2 = 6600
End
Begin VB.Line Line1
X1 = 120
X2 = 6000
Y1 = 600
Y2 = 600
End
End
Begin VB.Label Label5
Caption = "列"
Height = 255
Index = 1
Left = 1850
TabIndex = 10
Top = 280
Width = 255
End
Begin VB.Label Label4
Caption = "行"
Height = 255
Left = 910
TabIndex = 8
Top = 285
Width = 255
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public oQuZhenH, oQuZhenS As Integer
Public MaxCN As String
Dim Text As TextBox
'''实时生成图象判断
Private Sub Check1_Click()
If Check1.Value = 1 Then
Timer1.Enabled = True
Else
Timer1.Enabled = False
End If
End Sub
''''生成距阵
Private Sub Command1_Click()
''''不允许输入非数字
If IsNumeric(Text2.Text) = False Or IsNumeric(Text3.Text) = False Then
MsgBox "输入数字"
Exit Sub
Else
''''显示文本距阵和图形距阵
Call ShowMain(CInt(Text3.Text), CInt(Text2.Text))
End If
End Sub
''''填充图片
Private Sub Command2_Click()
On Error Resume Next
MaxCN = 0
For i = 1 To oQuZhenS
For n = 1 To oQuZhenH
MaxCN = MaxCN + 1
''''如果没有填写距阵元素,默认是空
If Text1(MaxCN) = "" Then
s = App.Path & "\pic\" & Text1(MaxCN) & "0.jpg"
Else
s = App.Path & "\pic\" & Text1(MaxCN) & ".jpg"
End If
'''加载图形
Picture1(MaxCN - 1).Picture = LoadPicture(s)
Next
Next
End Sub
Private Sub Form_Load()
'''启动窗体时默认加载10X10矩阵
Call ShowMain(10, 10)
End Sub
Private Function ShowMain(ByVal QuZhenH As Integer, ByVal QuZhenS As Integer)
On Error Resume Next
''''清除上一次的矩阵和标签
MaxCN = 0
For i = 1 To oQuZhenS
For n = 1 To oQuZhenH
MaxCN = MaxCN + 1
Unload Text1(MaxCN)
Unload Label2(MaxCN)
Unload Label3(MaxCN)
Unload Picture1(MaxCN)
''加载空格图片
Picture1(MaxCN - 1).Picture = LoadPicture(App.Path & "\pic\" & Text1(MaxCN) & "0.jpg")
Next
Next
Text1(0).Visible = False
MaxCN = 0
TextTop = Text1(0).Top
TextTop2 = Picture1(0).Top
'''初始化line长度
Line1.X2 = 500
Line2.Y2 = 500
Line3.Y2 = 600
Line4.X2 = 600
Label5(0).Top = 360
'''''生成距阵和图形距阵
For i = 1 To QuZhenS
TextLeft = 300
TextLeft2 = 0
For n = 1 To QuZhenH
MaxCN = MaxCN + 1
'''' 矩阵
Load Text1(MaxCN)
Text1(MaxCN).Width = Text1(0).Width
Text1(MaxCN).Height = Text1(0).Height
Text1(MaxCN).Left = TextLeft + 500
Text1(MaxCN).Top = TextTop
Text1(MaxCN).Text = ""
Text1(MaxCN).TabIndex = MaxCN
Text1(MaxCN).Visible = True
TextLeft = Text1(MaxCN).Left
'''' 图形
Load Picture1(MaxCN - 1)
Picture1(MaxCN - 1).Width = Picture1(0).Width
Picture1(MaxCN - 1).Height = Picture1(0).Height
Picture1(MaxCN - 1).Left = TextLeft2 + 600
Picture1(MaxCN - 1).Top = TextTop2
Picture1(MaxCN - 1).Visible = True
TextLeft2 = Picture1(MaxCN - 1).Left
Next
TextTop = TextTop + 500
TextTop2 = TextTop2 + 600
Next
''''调整line的长度
Line1.X2 = Line1.X2 * (QuZhenH + 1) + 300
Line2.Y2 = Line2.Y2 * (QuZhenS + 1) + 300
Line4.X2 = Line4.X2 * (QuZhenH + 1)
Line3.Y2 = Line3.Y2 * (QuZhenS + 1)
''''''生成竖标签
MaxCN = 0
For i = 1 To QuZhenS
MaxCN = MaxCN + 1
'''' 矩阵标签
TextTop = Label2(MaxCN - 1).Top + 500
Load Label2(MaxCN)
Label2(MaxCN).Width = Label2(0).Width
Label2(MaxCN).Height = Label2(0).Height
Label2(MaxCN).Top = TextTop
Label2(MaxCN).Caption = "v" & MaxCN
Label2(MaxCN).Visible = True
TextLeft = Label2(MaxCN).Left
'''' 图形标签
TextTop = Label5(MaxCN - 1).Top + 580
Load Label5(MaxCN)
Label5(MaxCN).Width = Label5(0).Width
Label5(MaxCN).Height = Label5(0).Height
Label5(MaxCN).Top = TextTop
Label5(MaxCN).Caption = "Row" & MaxCN
Label5(MaxCN).Visible = True
TextLeft = Label5(MaxCN).Left
Next
Label5(0).Top = 880
''''''生成横标签
MaxCN = 0
For i = 1 To QuZhenH
MaxCN = MaxCN + 1
'''' 矩阵标签
TextLeft = Label3(MaxCN - 1).Left + 500
Load Label3(MaxCN)
Label3(MaxCN).Width = Label3(0).Width
Label3(MaxCN).Height = Label3(0).Height
Label3(MaxCN).Left = TextLeft
Label3(MaxCN).Caption = "v" & MaxCN
Label3(MaxCN).Visible = True
TextLeft = Label3(MaxCN).Left
'''' 图形标签
TextLeft = Label6(MaxCN - 1).Left + 600
Load Label6(MaxCN)
Label6(MaxCN).Width = Label6(0).Width
Label6(MaxCN).Height = Label6(0).Height
Label6(MaxCN).Left = TextLeft
Label6(MaxCN).Caption = "Col" & MaxCN
Label6(MaxCN).Visible = True
TextLeft = Label6(MaxCN).Left
Next
'''保存上一次的距阵,用来清除
oQuZhenH = QuZhenH
oQuZhenS = QuZhenS
End Function
''''TIMER控件用来实时显示图形
Private Sub Timer1_Timer()
Call Command2_Click
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -