VB图书管理系统 第5页
Dim select_row As String
Dim showgrid2 As Boolean
Dim rs_custom As New ADODB.Recordset
Dim jinchu As String ' 进出库标志
Dim modify As Boolean ' 修改状态标志
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub Form_Load()
On Error GoTo loaderror
Dim sql As String
sql = "select * from 图书资料"
rs_custom.CursorLocation = adUseClient
rs_custom.Open sql, conn, adOpenKeyset, adLockPessimistic
While Not rs_custom.EOF
Combo1.AddItem rs_custom.Fields(0)
rs_custom.MoveNext
Wend
findok = True
modify = False ' 非修改状态
showgrid2 = False
displaygrid1 ' 调用显示Datagrid1子程序
loaderror:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
'显示msflexgrid1子程序
Public Sub displaygrid1()
Dim i As Integer
On Error GoTo displayerror
setgrid
setgridhead
MSFlexGrid1.Row = 0
If Not rs_data1.EOF Then
rs_data1.MoveFirst
Do While Not rs_data1.EOF
MSFlexGrid1.Row = MSFlexGrid1.Row + 1
MSFlexGrid1.Col = 0
If Not IsNull(rs_data1.Fields(0)) Then MSFlexGrid1.Text = rs_data1.Fields(0) Else
MSFlexGrid1.Text = ""
MSFlexGrid1.Col = 1
If Not IsNull(rs_data1.Fields(1)) Then MSFlexGrid1.Text = rs_data1.Fields(1) Else
MSFlexGrid1.Text = ""
MSFlexGrid1.Col = 2
If Not IsNull(rs_data1.Fields(2)) Then MSFlexGrid1.Text = rs_data1.Fields(2) Else
MSFlexGrid1.Text = ""
MSFlexGrid1.Col = 3
If Not IsNull(rs_data1.Fields(3)) Then MSFlexGrid1.Text = rs_data1.Fields(3) Else
MSFlexGrid1.Text = ""
MSFlexGrid1.Col = 4
If Not IsNull(rs_data1.Fields(4)) Then MSFlexGrid1.Text = rs_data1.Fields(4) Else
MSFlexGrid1.Text = ""
MSFlexGrid1.Col = 5
If Not IsNull(rs_data1.Fields(5)) Then MSFlexGrid1.Text = rs_data1.Fields(5) Else
MSFlexGrid1.Text = ""
rs_data1.MoveNext
Loop
End If
displayerror:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
Public Sub setgrid()
Dim i As Integer
On Error GoTo seterror
With MSFlexGrid1
.ScrollBars = flexScrollBarBoth
.FixedCols = 0
.Rows = rs_data1.RecordCount + 1
.Cols = 6
.SelectionMode = flexSelectionByRow
For i = 0 To .Rows - 1
.RowHeight(i) = 315
Next
For i = 0 To .Cols - 1
.ColWidth(i) = 1300
Next i
End With
Exit Sub
seterror:
MsgBox Err.Description
End Sub
Public Sub setgridhead()
On Error GoTo setheaderror
MSFlexGrid1.Row = 0
MSFlexGrid1.Col = 0
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] 下一页