其实用VB写DLL没有什么实际意义! 其实就是VB的一个可重用对象,也就是一个类 比如Option ExplicitPublic Sub FillGrid(ADOconn As ADODB.Connection, Grid As MSFlexGrid, adCmd As Integer, SQLstring As String, GridCol As Long, GridFormatString As String) Dim RstC As Integer, I As Integer, J As Integer Dim showRS As New ADODB.RecordsetWith Grid .Clear .Cols = GridCol .FixedCols = 0 .Rows = 1 .Clear .FormatString = GridFormatString Set showRS = New ADODB.Recordset showRS.CursorLocation = adUseClient showRS.Open SQLstring, ADOconn, adOpenKeyset, adLockReadOnly, adCmd If showRS.EOF Then .Rows = 20: Exit Sub showRS.MoveLast RstC = showRS.RecordCount showRS.MoveFirst For I = 1 To RstC .Rows = .Rows + 1 For J = 0 To GridCol - 1 .TextMatrix(.Rows - 1, J) = showRS.Fields(J).Value & "" Next showRS.MoveNext Next End With End Sub
其实就是VB的一个可重用对象,也就是一个类
比如Option ExplicitPublic Sub FillGrid(ADOconn As ADODB.Connection, Grid As MSFlexGrid, adCmd As Integer, SQLstring As String, GridCol As Long, GridFormatString As String)
Dim RstC As Integer, I As Integer, J As Integer
Dim showRS As New ADODB.RecordsetWith Grid
.Clear
.Cols = GridCol
.FixedCols = 0
.Rows = 1
.Clear
.FormatString = GridFormatString Set showRS = New ADODB.Recordset
showRS.CursorLocation = adUseClient
showRS.Open SQLstring, ADOconn, adOpenKeyset, adLockReadOnly, adCmd
If showRS.EOF Then .Rows = 20: Exit Sub
showRS.MoveLast
RstC = showRS.RecordCount
showRS.MoveFirst
For I = 1 To RstC
.Rows = .Rows + 1
For J = 0 To GridCol - 1
.TextMatrix(.Rows - 1, J) = showRS.Fields(J).Value & ""
Next
showRS.MoveNext
Next
End With
End Sub