📄 form1.ebf
字号:
VERSION 5.00
Object = "{532C2BF5-6B55-11D1-9AA5-00C04FAD5AEC}#1.0#0"; "MSCEGRID.DLL"
Begin VB.Form Form1
Appearance = 0 'Flat
BackColor = &H00FFC0C0&
Caption = "Form1"
ClientHeight = 4335
ClientLeft = 60
ClientTop = 840
ClientWidth = 3585
ForeColor = &H80000008&
ScaleHeight = 4335
ScaleWidth = 3585
ShowOK = -1 'True
Begin GRIDLibCtl.GridCtrl datagrid_index
Height = 2415
Left = 1800
TabIndex = 0
Top = 1200
Width = 1575
_cx = 2778
_cy = 4260
BackColor = 16777215
BackColorBkg = 8421504
BackColorSel = 6956042
Cols = 2
FillStyle = 0
FocusRect = 1
ForeColor = 0
ForeColorSel = 16777215
GridColor = 12632256
GridLines = 1
GridLineWidth = 1
HighLight = 1
Redraw = -1 'True
RowHeightMin = 0
Rows = 2
ScrollBars = 3
ScrollTrack = 0 'False
SelectionMode = 0
TextStyle = 0
WordWrap = 0 'False
Enabled = -1 'True
End
Begin GRIDLibCtl.GridCtrl datagrid
Height = 2415
Left = 0
TabIndex = 1
Top = 1200
Width = 1695
_cx = 2990
_cy = 4260
BackColor = 16777215
BackColorBkg = 8421504
BackColorSel = 6956042
Cols = 2
FillStyle = 0
FocusRect = 1
ForeColor = 0
ForeColorSel = 16777215
GridColor = 12632256
GridLines = 1
GridLineWidth = 1
HighLight = 1
Redraw = -1 'True
RowHeightMin = 0
Rows = 2
ScrollBars = 3
ScrollTrack = 0 'False
SelectionMode = 0
TextStyle = 0
WordWrap = 0 'False
Enabled = -1 'True
End
Begin VBCE.CommandButton but_delindex
Height = 375
Left = 120
TabIndex = 10
Top = 3620
Width = 1095
_cx = 1931
_cy = 661
BackColor = 12632256
Caption = "删除索引"
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Style = 0
End
Begin VBCE.Label Label3
Height = 375
Left = 240
TabIndex = 9
Top = 720
Width = 855
_cx = 1508
_cy = 661
AutoSize = 0 'False
BackColor = -2147483643
BackStyle = 1
BorderStyle = 0
Caption = "字段名称"
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = -2147483640
Alignment = 0
UseMnemonic = -1 'True
WordWrap = 0 'False
End
Begin VBCE.ComboBox cb_table_delindex
Height = 300
Left = 1080
TabIndex = 8
Top = 360
Width = 2295
List = "Form1.frx":0000
ItemData = "Form1.frx":0028
_cx = 4048
_cy = 529
BackColor = -2147483643
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = -2147483640
Text = ""
IntegralHeight = -1 'True
Locked = 0 'False
Sorted = 0 'False
Style = 0
End
Begin VBCE.Label Label2
Height = 255
Left = 0
TabIndex = 7
Top = 360
Width = 975
_cx = 1720
_cy = 450
AutoSize = 0 'False
BackColor = -2147483643
BackStyle = 1
BorderStyle = 0
Caption = "数据表名称"
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = -2147483640
Alignment = 0
UseMnemonic = -1 'True
WordWrap = 0 'False
End
Begin VBCE.ComboBox cb_dbname_delindex
Height = 300
Left = 1080
TabIndex = 6
Top = 0
Width = 2295
List = "Form1.frx":0050
ItemData = "Form1.frx":0078
_cx = 4048
_cy = 529
BackColor = -2147483643
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = -2147483640
Text = ""
IntegralHeight = -1 'True
Locked = 0 'False
Sorted = 0 'False
Style = 0
End
Begin VBCE.Label Label1
Height = 255
Left = 0
TabIndex = 5
Top = 0
Width = 975
_cx = 1720
_cy = 450
AutoSize = 0 'False
BackColor = -2147483643
BackStyle = 1
BorderStyle = 0
Caption = "数据库名称"
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = -2147483640
Alignment = 0
UseMnemonic = -1 'True
WordWrap = 0 'False
End
Begin VBCE.Label Label4
Height = 375
Left = 2040
TabIndex = 4
Top = 720
Width = 975
_cx = 1720
_cy = 661
AutoSize = 0 'False
BackColor = -2147483643
BackStyle = 1
BorderStyle = 0
Caption = "索引名称"
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = -2147483640
Alignment = 0
UseMnemonic = -1 'True
WordWrap = 0 'False
End
Begin VBCE.CommandButton but_cancel
Height = 375
Left = 1560
TabIndex = 3
Top = 3620
Width = 1215
_cx = 2143
_cy = 661
BackColor = 12632256
Caption = "取消"
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Style = 0
End
Begin VBCE.ListBox lb_tableid
Height = 1005
Left = 3600
TabIndex = 2
Top = 1560
Visible = 0 'False
Width = 1215
List = "Form1.frx":00A0
ItemData = "Form1.frx":00C8
_cx = 2143
_cy = 1773
BackColor = -2147483643
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = -2147483640
Columns = 0
IntegralHeight = -1 'True
MultiSelect = 0
Sorted = 0 'False
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub but_delindex_Click()
If datagrid_index.RowSel < 0 Then
MsgBox "请选择需要创建索引的字段", vbOKOnly, "提醒"
Exit Sub
ElseIf datagrid_index.RowSel = 0 Then
MsgBox "不能选择字段名称", vbOKOnly, "提醒"
Exit Sub
End If
If Not table.State = adStateClosed Then
table.Close
End If
Dim okornot As Integer
Dim sql, addition As String
okornot = MsgBox("是否删除索引?", vbOKCancel + vbQuestion, "提醒")
If okornot = vbOK Then
sql = "DROP INDEX " & cb_table_delindex.List(cb_table_delindex.ListIndex) & "." & datagrid_index.TextMatrix(datagrid_index.RowSel, 0) & " "
Connection.Execute sql
If Err.Number > 0 Then
MsgBox "索引删除错误,请检查", vbOKOnly, "注意"
Else
MsgBox "索引删除成功,请检查", vbOKOnly, "注意"
End If
End If
End Sub
Private Sub form1_Click()
If Not table.State = adStateClosed Then
table.Close
End If
table.Open Form1.List(Form1.ListIndex), Connection
If table.RecordCount > 0 Then
If table.BOF And table.EOF Then
MsgBox table & " 没有任何记录", vbOKOnly, "注意"
Exit Sub
ElseIf Len(Form1.List(Form1.ListIndex)) = 0 Then
Exit Sub
Else
showallfields del_index
End If
Else
MsgBox " 没有任何记录", vbOKOnly, "注意"
Exit Sub
End If
getallindex
End Sub
Private Sub cb_table_delindex_Click()
If Not table.State = adStateClosed Then
table.Close
End If
table.Open cb_table_delindex.List(cb_table_delindex.ListIndex), Connection
If table.RecordCount > 0 Then
If table.BOF And table.EOF Then
MsgBox table & " 没有任何记录", vbOKOnly, "注意"
Exit Sub
ElseIf Len(cb_table_delindex.List(cb_table_delindex.ListIndex)) = 0 Then
Exit Sub
Else
showallfields Form1
End If
Else
MsgBox " 没有任何记录", vbOKOnly, "注意"
Exit Sub
End If
getallindex
End Sub
Private Sub Form_Load()
If Not table.State = adStateClosed Then
table.Close
End If
table.Open "MSysTables", Connection
table.MoveFirst
Do While Not table.EOF
If table.fields("TableName") <> "MSysTables" And _
table.fields("TableName") <> "MSysFields" And _
table.fields("TableName") <> "MSysIndexes" And _
table.fields("TableName") <> "MSysProcs" Then
cb_table_delindex.AddItem table.fields("TableName")
lb_tableid.AddItem table.fields("TableID")
End If
table.MoveNext
Loop
cb_table_delindex.ListIndex = 0
cb_dbname_delindex.Text = "books"
End Sub
Public Sub getallindex()
Dim i As Integer
If Not table.State = adStateClosed Then
table.Close
End If
table.Open "MSysIndexes", Connection
If table.BOF And table.EOF Then
MsgBox table & " 没有任何记录", vbOKOnly, "注意"
End If
Dim s As Integer
s = datagrid_index.Rows
For i = 1 To s
datagrid_index.RemoveItem 0
Next
Dim title, m As String
Dim data As String
m = table.RecordCount
datagrid_index.Cols = table.fields.Count
Dim xxx As Integer
xxx = datagrid_index.Cols - 1
datagrid_index.AddItem "索引名称"
table.MoveFirst
Dim j As Integer
For i = 1 To table.RecordCount
If table.fields("TableID").Value = CLng(lb_tableid.List(cb_table_delindex.ListIndex)) Then
If data & table.fields("Indexname").Value <> "PrimaryKey" Then
data = data & table.fields("Indexname").Value
datagrid_index.ColWidth(0) = Len(table.fields("Indexname").Name) + 1400
datagrid_index.AddItem data
End If
End If
data = ""
table.MoveNext
Next
datagrid_index.Redraw = True
End Sub
Private Sub Form_OKClick()
App.End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -