?? 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) & "的貨物數(shù)據(jù)么?", 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) & "的集裝箱數(shù)據(jù)么?", 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) & "的托盤數(shù)據(jù)么?", 308, "刪除確認!")
If a = 6 Then
ListView2.ListItems.Remove (ListView2.SelectedItem.Index)
End If
End If
End Sub
'========================================================================================================
'=================================判斷輸入是否為數(shù)字=====================================================
Private Function checkinput(obj As TextBox, num_type As Integer) As Boolean
If IsNumeric(obj.Text) Then
Select Case num_type
Case 0 '只要是數(shù)字
checkinput = True
Case 1 '必須為整數(shù)
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 "沒有選擇要裝箱的貨物或者要裝箱的貨物數(shù)量為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
'選擇的優(yōu)先策略
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里的數(shù)據(jù)
hc = False 'New Code
End Sub
'========================================================================================================
'初始化listview里的數(shù)據(jù)
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) ' 循環(huán)至文件尾。
I = I + 1
Line Input #1, textline ' 讀入一行數(shù)據(jù)。
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) ' 循環(huán)至文件尾。
I = I + 1
Line Input #1, textline ' 讀入一行數(shù)據(jù)。
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) ' 循環(huán)至文件尾。
I = I + 1
Line Input #1, textline ' 讀入一行數(shù)據(jù)。
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 "輸入格式錯誤,請檢查!當前要求輸入數(shù)字。", 48, "輸入錯誤!"
KeyAscii = 0
End If
ElseIf Index = 5 Then
If KeyAscii > 57 Or KeyAscii < 48 Then
MsgBox "輸入格式錯誤,請檢查!當前要求輸入整數(shù)。", 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 "輸入格式錯誤,請檢查!當前要求輸入數(shù)字。", 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 "輸入格式錯誤,請檢查!當前要求輸入數(shù)字。", 48, "輸入錯誤!"
KeyAscii = 0
End If
End If
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -