📄 form3.frm
字号:
'OICQ :88382850
' 如果您有新的好的代码别忘记给枕善居哦!
'****************************************************************************
'==========================================货物列表编辑==================================================
'增加货物列表
Private Sub Command1_Click()
Set itmx = ListView3.ListItems.Add(, , "")
For I = 1 To 6
itmx.SubItems(I) = Text1(I - 1).Text
Next I
itmx.SubItems(6) = CStr(CInt(Text1(5).Text))
End Sub
'修改货物列表
Private Sub Command2_Click()
ListView3.SelectedItem.SubItems(1) = Text1(0).Text
ListView3.SelectedItem.SubItems(2) = Text1(1).Text
ListView3.SelectedItem.SubItems(3) = Text1(2).Text
ListView3.SelectedItem.SubItems(4) = Text1(3).Text
ListView3.SelectedItem.SubItems(5) = Text1(4).Text
ListView3.SelectedItem.SubItems(6) = CStr(CInt(Text1(5).Text))
End Sub
'删除货物列表
Private Sub Command3_Click()
If ListView3.SelectedItem.Text = "" Then
MsgBox "请选择要删除的行!"
ElseIf ListView3.SelectedItem.Text = "√" Then
a = MsgBox("确定要从列表中删除名称为" & ListView3.SelectedItem.SubItems(1) & "的货物数据么?", 308, "删除确认!")
If a = 6 Then
ListView3.ListItems.Remove (ListView3.SelectedItem.Index)
End If
End If
End Sub
'========================================================================================================
'=========================================集装箱列表编辑=================================================
'增加集装箱列表
Private Sub Command8_Click()
Set itmx = ListView1.ListItems.Add(, , "")
For I = 1 To 5
itmx.SubItems(I) = Text1(I - 1).Text
Next I
End Sub
'修改集装箱列表
Private Sub Command7_Click()
ListView1.SelectedItem.SubItems(1) = Text2(0).Text
ListView1.SelectedItem.SubItems(2) = Text2(1).Text
ListView1.SelectedItem.SubItems(3) = Text2(2).Text
ListView1.SelectedItem.SubItems(4) = Text2(3).Text
ListView1.SelectedItem.SubItems(5) = Text2(4).Text
End Sub
'删除集装箱列表
Private Sub Command6_Click()
If ListView1.SelectedItem.Text = "" Then
MsgBox "请选择要删除的行!"
ElseIf ListView1.SelectedItem.Text = "√" Then
a = MsgBox("确定要从列表中删除名称为" & ListView1.SelectedItem.SubItems(1) & "的集装箱数据么?", 308, "删除确认!")
If a = 6 Then
ListView1.ListItems.Remove (ListView1.SelectedItem.Index)
End If
End If
End Sub
'========================================================================================================
'==========================================托盘列表编辑==================================================
'增加托盘列表
Private Sub Command11_Click()
Set itmx = ListView2.ListItems.Add(, , "")
For I = 1 To 6
itmx.SubItems(I) = Text1(I - 1).Text
Next I
End Sub
'修改托盘列表
Private Sub Command10_Click()
ListView2.SelectedItem.SubItems(1) = Text3(0).Text
ListView2.SelectedItem.SubItems(2) = Text3(1).Text
ListView2.SelectedItem.SubItems(3) = Text3(2).Text
ListView2.SelectedItem.SubItems(4) = Text3(3).Text
ListView2.SelectedItem.SubItems(5) = Text3(4).Text
ListView2.SelectedItem.SubItems(6) = Text3(5).Text
End Sub
'删除托盘列表
Private Sub Command9_Click()
If ListView2.SelectedItem.Text = "" Then
MsgBox "请选择要删除的行!"
ElseIf ListView2.SelectedItem.Text = "√" Then
a = MsgBox("确定要从列表中删除名称为" & ListView2.SelectedItem.SubItems(1) & "的托盘数据么?", 308, "删除确认!")
If a = 6 Then
ListView2.ListItems.Remove (ListView2.SelectedItem.Index)
End If
End If
End Sub
'========================================================================================================
'=================================判断输入是否为数字=====================================================
Private Function checkinput(obj As TextBox, num_type As Integer) As Boolean
If IsNumeric(obj.Text) Then
Select Case num_type
Case 0 '只要是数字
checkinput = True
Case 1 '必须为整数
If CSng(obj.Text) Mod 1 = 0 Then
checkinput = True
Else
checkinput = False
End If
Case Else
checkinput = False
End Select
Else
checkinput = False
End If
End Function
Private Sub Command4_Click()
'判断使用集装箱还是托盘并判断列表中是否有选中的集装箱或者托盘
If Option1(0).Value = True Then
Dim containers As Boolean
containers = False
For Each items In ListView1.ListItems
If items.Text = "√" Then containers = True
Next
If Not containers Then
MsgBox "没有选择集装箱", 48, "错误!"
Exit Sub
End If
ElseIf Option1(1).Value = True Then
Dim trays As Boolean
trays = False
For Each items In ListView2.ListItems
If items.Text = "√" Then trays = True
Next
If Not trays Then
MsgBox "没有选择托盘", 48, "错误!"
Exit Sub
End If
End If
'检查是否有待装货物
Dim goods As Boolean
goods = False
For Each items In ListView3.ListItems
If items.Text = "√" And CInt(items.SubItems(6)) > 0 Then goods = True
Next
If Not goods Then
MsgBox "没有选择要装箱的货物或者要装箱的货物数量为0", 48, "错误!"
Exit Sub
End If
'检查装箱策略选择
Dim check1flag As Boolean
check1flag = False
For Each check In Check1
If check.Value = 1 Then check1flag = True
Next
If Not check1flag Then
MsgBox "没有选择装箱策略", 48, "错误!"
Exit Sub
End If
'检查工作面拆分策略选择
Dim check2flag As Boolean
check2flag = False
For Each check In Check2
If check.Value = 1 Then check2flag = True
Next
If Not check2flag Then
MsgBox "没有选择工作面拆分策略", 48, "错误!"
Exit Sub
End If
'检查剩余空间拆分策略选择
Dim check3flag As Boolean
check3flag = False
For Each check In Option2
If check.Value = True Then check3flag = True
Next
If Not check3flag Then
MsgBox "没有选择剩余空间拆分策略", 48, "错误!"
Exit Sub
End If
'验证通过,加载清单窗体
Load Form4
'选择的容器
If Option1(0).Value = True Then
For Each items In ListView1.ListItems
If items.Text = "√" Then
Set itmx = Form4.ListView2.ListItems.Add(, , "√")
For I = 1 To 5
itmx.SubItems(I) = items.SubItems(I)
Next I
End If
Next
hc = True 'New Code
ElseIf Option1(1).Value = True Then
For Each items In ListView2.ListItems
If items.Text = "√" Then
Set itmx = Form4.ListView2.ListItems.Add(, , "√")
For I = 1 To 6
itmx.SubItems(I) = items.SubItems(I)
Next I
End If
Next
hc = False 'New Code
End If
'选择的货物
For Each items In ListView3.ListItems
If items.Text = "√" And CInt(items.SubItems(6)) > 0 Then
Set itmx = Form4.ListView3.ListItems.Add(, , "√")
For I = 1 To 6
itmx.SubItems(I) = items.SubItems(I)
Next I
End If
Next
'选择的优先策略
For Each check In Check1
If check.Value = 1 Then
Form4.Check1(check.Index).Value = 1
Else
Form4.Check1(check.Index).Value = 0
End If
Next
'选择的拆分策略
For Each check In Check2
If check.Value = 1 Then
Form4.Check2(check.Index).Value = 1
Else
Form4.Check2(check.Index).Value = 0
End If
Next
'剩余空间拆分策略
For Each check In Option2
If check.Value = True Then
Form4.Option2(check.Index).Value = True
Else
Form4.Option2(check.Index).Value = False
End If
Next
Form4.getcount
Form4.Show
End Sub
'========================================================================================================
Private Sub Command5_Click()
For Each items In ListView1.ListItems
If items.Text = "√" Then MsgBox "选中了" + CStr(items.Index)
Next
End Sub
'========================================================================================================
Private Sub Form_Load()
initlistview '初始化listview里的数据
hc = False 'New Code
End Sub
'========================================================================================================
'初始化listview里的数据
Public Sub initlistview()
'集装箱列表
Open App.Path + "\containers.txt" For Input As #1
Seek #1, 1
ListView1.ListItems.Clear
I = 0
Do While Not EOF(1) ' 循环至文件尾。
I = I + 1
Line Input #1, textline ' 读入一行数据。
temps = Split(textline, "|")
Set itmx = ListView1.ListItems.Add(, , "")
For I = 0 To UBound(temps)
itmx.SubItems(I + 1) = temps(I)
Next I
DoEvents
Loop
Close
'托盘列表
Open App.Path + "\trays.txt" For Input As #1
Seek #1, 1
ListView2.ListItems.Clear
I = 0
Do While Not EOF(1) ' 循环至文件尾。
I = I + 1
Line Input #1, textline ' 读入一行数据。
temps = Split(textline, "|")
Set itmx = ListView2.ListItems.Add(, , "")
For I = 0 To UBound(temps)
itmx.SubItems(I + 1) = temps(I)
Next I
DoEvents
Loop
Close
'货物列表
Open App.Path + "\goods.txt" For Input As #1
Seek #1, 1
ListView3.ListItems.Clear
I = 0
Do While Not EOF(1) ' 循环至文件尾。
I = I + 1
Line Input #1, textline ' 读入一行数据。
temps = Split(textline, "|")
Set itmx = ListView3.ListItems.Add(, , "")
For I = 0 To UBound(temps)
itmx.SubItems(I + 1) = temps(I)
Next I
If itmx.SubItems(6) = "" Then itmx.SubItems(6) = "0"
If CInt(itmx.SubItems(6)) > 0 Then itmx.Text = "√"
DoEvents
Loop
Close
End Sub
'========================================================================================================
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
If Item.Text = "" Then
Item.Text = "√"
Else
Item.Text = ""
End If
Text2(0).Text = Item.SubItems(1)
Text2(1).Text = Item.SubItems(2)
Text2(2).Text = Item.SubItems(3)
Text2(3).Text = Item.SubItems(4)
Text2(4).Text = Item.SubItems(5)
End Sub
Private Sub ListView2_ItemClick(ByVal Item As MSComctlLib.ListItem)
If Item.Text = "" Then
Item.Text = "√"
Else
Item.Text = ""
End If
Text3(0).Text = Item.SubItems(1)
Text3(1).Text = Item.SubItems(2)
Text3(2).Text = Item.SubItems(3)
Text3(3).Text = Item.SubItems(4)
Text3(4).Text = Item.SubItems(5)
Text3(5).Text = Item.SubItems(6)
End Sub
Private Sub ListView3_ItemClick(ByVal Item As MSComctlLib.ListItem)
If Item.Text = "" Then
Item.Text = "√"
Else
Item.Text = ""
End If
Text1(0).Text = Item.SubItems(1)
Text1(1).Text = Item.SubItems(2)
Text1(2).Text = Item.SubItems(3)
Text1(3).Text = Item.SubItems(4)
Text1(4).Text = Item.SubItems(5)
Text1(5).Text = Item.SubItems(6)
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If Index > 0 And Index < 5 Then
If KeyAscii > 57 Or KeyAscii < 46 Or KeyAscii = 47 Then
MsgBox "输入格式错误,请检查!当前要求输入数字。", 48, "输入错误!"
KeyAscii = 0
End If
ElseIf Index = 5 Then
If KeyAscii > 57 Or KeyAscii < 48 Then
MsgBox "输入格式错误,请检查!当前要求输入整数。", 48, "输入错误!"
KeyAscii = 0
End If
End If
End Sub
Private Sub Text2_KeyPress(Index As Integer, KeyAscii As Integer)
If Index > 0 Then
If KeyAscii > 57 Or KeyAscii < 46 Or KeyAscii = 47 Then
MsgBox "输入格式错误,请检查!当前要求输入数字。", 48, "输入错误!"
KeyAscii = 0
End If
End If
End Sub
Private Sub Text3_KeyPress(Index As Integer, KeyAscii As Integer)
If Index > 0 Then
If KeyAscii > 57 Or KeyAscii < 46 Or KeyAscii = 47 Then
MsgBox "输入格式错误,请检查!当前要求输入数字。", 48, "输入错误!"
KeyAscii = 0
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -