?? form24.frm
字號:
VERSION 5.00
Begin VB.Form Form24
Caption = "Form24"
ClientHeight = 6960
ClientLeft = 60
ClientTop = 450
ClientWidth = 8685
LinkTopic = "Form24"
ScaleHeight = 6960
ScaleWidth = 8685
StartUpPosition = 3 '窗口缺省
Begin VB.ListBox List1
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 5340
Left = 600
TabIndex = 1
Top = 720
Width = 7455
End
Begin VB.CommandButton Command1
Caption = "刪除數據"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 420
Left = 3600
TabIndex = 0
Top = 6360
Width = 1455
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "費用項目查詢畫面"
BeginProperty Font
Name = "宋體"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 3000
TabIndex = 3
Top = 240
Width = 2520
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 = 600
TabIndex = 2
Top = 480
Width = 1335
End
End
Attribute VB_Name = "Form24"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim arr_charge_name(50)
Private Sub Command1_Click()
Dim cnn1 As ADODB.Connection
Dim cmd1 As ADODB.Command
Dim rs1 As ADODB.Recordset
Set cnn1 = New ADODB.Connection
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\jujumao\My Documents\粵豐飼料\粵豐飼料經營情況.mdb;"
Set cmd1 = New ADODB.Command
SQL = "select count(*) from 費用明細表 where 費用名稱=" & "'" & arr_charge_name(List1.ListIndex) & "'"
With cmd1
.ActiveConnection = cnn1
.CommandText = SQL
.CommandType = adCmdText
End With
Set rs1 = cmd1.Execute
rs1.MoveFirst
If rs1.Fields(0) > 0 Then
MsgBox ("已有數據,不能刪除該項目!")
GoTo m_exit
End If
SQL = "delete from 費用項目表 where 費用名稱=" & "'" & arr_charge_name(List1.ListIndex) & "'"
With cmd1
.ActiveConnection = cnn1
.CommandText = SQL
.CommandType = adCmdText
.Execute
End With
SQL = "select 費用名稱 from 費用項目表 "
With cmd1
.ActiveConnection = cnn1
.CommandText = SQL
.CommandType = adCmdText
End With
Set rs1 = cmd1.Execute
j = 0
List1.Clear
If rs1.EOF Then
MsgBox ("沒有查詢到記錄")
Command1.Enabled = False
GoSub m_exit
End If
rs1.MoveFirst
While Not rs1.EOF
S = ""
For i = 0 To rs1.Fields.Count - 1
t_len = 11 - Len(rs1.Fields(i).Value)
S1 = ""
For t = 1 To t_len
S1 = S1 & " "
Next
S = S & rs1.Fields(i).Value & S1
Next
List1.AddItem S, j
arr_charge_name(j) = rs1.Fields(0).Value
j = j + 1
rs1.MoveNext
Wend
List1.ListIndex = 0
m_exit:
cnn1.Close
Set cnn1 = Nothing
End Sub
Private Sub Form_Load()
Dim cnn1 As ADODB.Connection
Dim cmd1 As ADODB.Command
Dim rs1 As ADODB.Recordset
Set cnn1 = New ADODB.Connection
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\jujumao\My Documents\粵豐飼料\粵豐飼料經營情況.mdb;"
Set cmd1 = New ADODB.Command
SQL = "select 費用名稱 from 費用項目表 "
With cmd1
.ActiveConnection = cnn1
.CommandText = SQL
.CommandType = adCmdText
End With
Set rs1 = cmd1.Execute
j = 0
If rs1.EOF Then
MsgBox ("沒有查詢到記錄")
Command1.Enabled = False
GoSub m_exit
End If
rs1.MoveFirst
While Not rs1.EOF
S = ""
For i = 0 To rs1.Fields.Count - 1
If i = 0 Then
tt_len = Len(rs1.Fields(i).Value)
t_len = 0
For t = 1 To tt_len
If Asc((Mid((rs1.Fields(i).Value), t, 1))) < 0 Then
t_len = t_len + 2
Else
t_len = t_len + 1
End If
Next
t_len = 11 - t_len
Else
t_len = 11 - Len(rs1.Fields(i).Value)
End If
S1 = ""
For t = 1 To t_len
S1 = S1 & " "
Next
S = S & rs1.Fields(i).Value & S1
Next
List1.AddItem S, j
arr_charge_name(j) = rs1.Fields(0).Value
j = j + 1
rs1.MoveNext
Wend
List1.ListIndex = 0
m_exit:
cnn1.Close
Set cnn1 = Nothing
End Sub
Private Sub Form_Unload(Cancel As Integer)
Form5.Show
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -