📄 selectnanopinion_frm.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form selectnanopinion_frm
Caption = "查看关于市民的一些道德观"
ClientHeight = 7755
ClientLeft = 4920
ClientTop = 1980
ClientWidth = 6660
LinkTopic = "Form1"
MaxButton = 0 'False
Picture = "selectnanopinion_frm.frx":0000
ScaleHeight = 7755
ScaleWidth = 6660
Begin MSAdodcLib.Adodc Ado
Height = 330
Left = 2400
Top = 2640
Visible = 0 'False
Width = 1200
_ExtentX = 2117
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Frame Frame1
BackColor = &H00FFC0C0&
Height = 2295
Left = 1200
TabIndex = 1
Top = 4440
Width = 5295
Begin VB.ComboBox Combo1
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 360
Left = 3240
TabIndex = 5
Top = 720
Width = 1935
End
Begin VB.CommandButton Command3
Caption = "删 除"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3360
TabIndex = 4
Top = 1320
Width = 1575
End
Begin VB.CommandButton Command2
Caption = "退出查询"
Height = 495
Left = 360
TabIndex = 3
Top = 1440
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "查 询"
Height = 495
Left = 360
TabIndex = 2
Top = 360
Width = 1455
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "请选择要删除的记录"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3240
TabIndex = 6
Top = 360
Width = 2535
End
Begin VB.Image Image1
Height = 1200
Left = 1680
Picture = "selectnanopinion_frm.frx":2808C
Top = 360
Width = 1500
End
End
Begin MSFlexGridLib.MSFlexGrid myFlexgrid
Height = 3375
Left = 840
TabIndex = 0
Top = 720
Width = 5775
_ExtentX = 10186
_ExtentY = 5953
_Version = 393216
Rows = 9
Cols = 6
BackColorBkg = 4194368
AllowUserResizing= 3
End
End
Attribute VB_Name = "selectnanopinion_frm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command1_Click()
'先关闭记录集
Ado.Recordset.Close
Ado.Recordset.Open "select * from daode"
'利用控件 MSFlexGrid来显示查询结果
With myFlexgrid
.Rows = 3
.CellAlignment = 1
.TextMatrix(1, 0) = "用户编号"
.TextMatrix(1, 1) = "第一道结果"
.TextMatrix(1, 2) = "第二道结果"
.TextMatrix(1, 3) = "第三道结果"
.TextMatrix(1, 4) = "第四道结果"
.TextMatrix(1, 5) = "第五道结果"
'把记录集中的数据用myFlexgrid来显示,并且行自动增长
Do While Not Ado.Recordset.EOF
.Rows = .Rows + 1
.CellAlignment = 2
'看记录集中的数据是否是空的
If IsNull(Ado.Recordset.Fields(0)) Then
.TextMatrix(.Rows - 1, 0) = ""
Else
.TextMatrix(.Rows - 1, 0) = Ado.Recordset.Fields(0)
End If
'看记录集中的数据是否是空的
If IsNull(Ado.Recordset.Fields(1)) Then
.TextMatrix(.Rows - 1, 1) = " "
Else
.TextMatrix(.Rows - 1, 1) = Ado.Recordset.Fields(1)
End If
'看记录集中的数据是否是空的
If IsNull(Ado.Recordset.Fields(2)) Then
.TextMatrix(.Rows - 1, 2) = ""
Else
.TextMatrix(.Rows - 1, 2) = Ado.Recordset.Fields(2)
End If
'看记录集中的数据是否是空的
If IsNull(Ado.Recordset.Fields(3)) Then
.TextMatrix(.Rows - 1, 3) = ""
Else
.TextMatrix(.Rows - 1, 3) = Ado.Recordset.Fields(3)
End If
'看记录集中的数据是否是空的
If IsNull(Ado.Recordset.Fields(4)) Then
.TextMatrix(.Rows - 1, 4) = ""
Else
.TextMatrix(.Rows - 1, 4) = Ado.Recordset.Fields(4)
End If
'看记录集中的数据是否是空的
If IsNull(Ado.Recordset.Fields(5)) Then
.TextMatrix(.Rows - 1, 5) = ""
Else
.TextMatrix(.Rows - 1, 5) = Ado.Recordset.Fields(5)
End If
'记录集往下移
Ado.Recordset.MoveNext
Loop
End With
End Sub
'创建一个函数把记录集中的数据在myFlexgrid中显示
Public Sub viewdata()
myFlexgrid.TextMatrix(Rows - 1, 0) = Ado.Recordset.Fields(0)
myFlexgrid.TextMatrix(Rows - 1, 1) = Ado.Recordset.Fields(1)
myFlexgrid.TextMatrix(Rows - 1, 2) = Ado.Recordset.Fields(2)
myFlexgrid.TextMatrix(Rows - 1, 3) = Ado.Recordset.Fields(3)
myFlexgrid.TextMatrix(Rows - 1, 4) = Ado.Recordset.Fields(4)
myFlexgrid.TextMatrix(Rows - 1, 5) = Ado.Recordset.Fields(5)
End Sub
Private Sub Command3_Click()
If Combo1.Text = "" Then
MsgBox "请你选择要删除的用户编号!", vbOKOnly + vbExclamation, "提示"
Exit Sub
End If
Ado.Recordset.Close
Ado.Recordset.Open "select * from daode where num= " & CInt(Combo1.Text) & " "
On Error Resume Next
Ado.Recordset.Delete
End Sub
Private Sub Form_Load()
Dim a As Integer
'利用ADO控件来连接数据库中的daode表
Ado.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db1.mdb"
Ado.CommandType = adCmdText
Ado.RecordSource = "select * from daode"
Ado.Refresh
For a = 0 To Ado.Recordset.RecordCount - 1
Combo1.AddItem Ado.Recordset.Fields(0)
If Ado.Recordset.EOF = False Then
Ado.Recordset.MoveNext
End If
Next
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -