VB 对象打开时不允许操作:错误3705 第一打开窗体可以,第二次加载同一窗体时出错
PublicSubLoadListUser()readServerDimitmXAsListItemDimrsAsADODB.RecordsetSetrs=NewADOD...
Public Sub LoadListUser()
readServer
Dim itmX As ListItem
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
List1.ListItems.Clear
sqlConnect cnMain, strSQLServer, strSQLUser, strSQLPW, strSQLDB
rs.Open "select * from PrintUser order by UserID", cnMain, 1, 1
If Not rs.EOF Then
Do While Not rs.EOF
Set itmX = List1.ListItems.Add(, , rs.Fields("UserName"))
With itmX
.SubItems(1) = IIf(IsNull(rs.Fields("UserDepartment")), "", rs.Fields("UserDepartment"))
.ListSubItems(1).ForeColor = vbBlue
.SubItems(2) = IIf(IsNull(rs.Fields("Userphone")), "", rs.Fields("Userphone"))
.SubItems(3) = IIf(IsNull(rs.Fields("UserEmail")), "", rs.Fields("UserEmail"))
.ListSubItems(3).ForeColor = vbRed
.SubItems(4) = IIf(IsNull(rs.Fields("UserGroup")), "", rs.Fields("UserGroup"))
.SubItems(5) = IIf(IsNull(rs.Fields("UserState")), "", rs.Fields("UserState"))
.SubItems(6) = IIf(IsNull(rs.Fields("userBTotalPages")), 0, rs.Fields("userBTotalPages"))
.ListSubItems(6).ForeColor = vbBlue
.SubItems(7) = IIf(IsNull(rs.Fields("userctotalpages")), 0, rs.Fields("userctotalpages"))
.ListSubItems(7).ForeColor = vbBlue
.SubItems(8) = Val(rs.Fields("usermoneytotal")) - (rs.Fields("userbtotalpages") * Val(rs.Fields("UserPriceBlack")))
If .SubItems(8) < 0 Then
FrmMain.LBSB(3).caption = "请及时充值!"
FrmMain.LBSB(3).ForeColor = vbRed
End If
.SubItems(9) = CDbl(IIf(IsNull(rs.Fields("UserBtotalPages")), 0, rs.Fields("UserBtotalPages"))) * CDbl(IIf(IsNull(rs.Fields("UserPriceBlack")), 0, rs.Fields("UserPriceBlack")))
.SubItems(10) = IIf(IsNull(rs.Fields("userGreatTime")), "", rs.Fields("userGreatTime"))
End With
rs.MoveNext
Loop
End If
End Sub
Private Sub Form_Load()
Me.WindowState = 2
LoadListUser
End Sub
搞定了,谢谢。
cnMain.close 展开
readServer
Dim itmX As ListItem
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
List1.ListItems.Clear
sqlConnect cnMain, strSQLServer, strSQLUser, strSQLPW, strSQLDB
rs.Open "select * from PrintUser order by UserID", cnMain, 1, 1
If Not rs.EOF Then
Do While Not rs.EOF
Set itmX = List1.ListItems.Add(, , rs.Fields("UserName"))
With itmX
.SubItems(1) = IIf(IsNull(rs.Fields("UserDepartment")), "", rs.Fields("UserDepartment"))
.ListSubItems(1).ForeColor = vbBlue
.SubItems(2) = IIf(IsNull(rs.Fields("Userphone")), "", rs.Fields("Userphone"))
.SubItems(3) = IIf(IsNull(rs.Fields("UserEmail")), "", rs.Fields("UserEmail"))
.ListSubItems(3).ForeColor = vbRed
.SubItems(4) = IIf(IsNull(rs.Fields("UserGroup")), "", rs.Fields("UserGroup"))
.SubItems(5) = IIf(IsNull(rs.Fields("UserState")), "", rs.Fields("UserState"))
.SubItems(6) = IIf(IsNull(rs.Fields("userBTotalPages")), 0, rs.Fields("userBTotalPages"))
.ListSubItems(6).ForeColor = vbBlue
.SubItems(7) = IIf(IsNull(rs.Fields("userctotalpages")), 0, rs.Fields("userctotalpages"))
.ListSubItems(7).ForeColor = vbBlue
.SubItems(8) = Val(rs.Fields("usermoneytotal")) - (rs.Fields("userbtotalpages") * Val(rs.Fields("UserPriceBlack")))
If .SubItems(8) < 0 Then
FrmMain.LBSB(3).caption = "请及时充值!"
FrmMain.LBSB(3).ForeColor = vbRed
End If
.SubItems(9) = CDbl(IIf(IsNull(rs.Fields("UserBtotalPages")), 0, rs.Fields("UserBtotalPages"))) * CDbl(IIf(IsNull(rs.Fields("UserPriceBlack")), 0, rs.Fields("UserPriceBlack")))
.SubItems(10) = IIf(IsNull(rs.Fields("userGreatTime")), "", rs.Fields("userGreatTime"))
End With
rs.MoveNext
Loop
End If
End Sub
Private Sub Form_Load()
Me.WindowState = 2
LoadListUser
End Sub
搞定了,谢谢。
cnMain.close 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询