for i=0 to combo.listcount-1 if 没有其中的值 then combo.listindex=-1 else combo.listindex=i:exit for next
for i=0 to cboLogin.listcount-1 if strLogin<>cboLogin.list(i) then cboLogin.listindex=-1 else cboLogin.listindex=i exit for end if next
Dim strLogin As String * 255 '最后登录人姓名 Dim n As Integer INIFileName$ = App.Path & "\" & strCFG_FileNamen = GetPrivateProfileString("INFO", "LastLogin", "", strLogin, Len(strLogin), INIFileName) strLogin = Left(strLogin, n) '读取INI里面最后登陆者的名字 Call objConnDim rsLoad As New ADODB.Recordset sqlLoad$ = "SELECT RealName,UserName FROM ADMIN ORDER BY UserName ASC" rsLoad.Open sqlLoad, conn, 1, 1 If cboUserName.ListCount <> rsLoad.RecordCount Then cboUserName.Clear While rsLoad.EOF = False cboUserName.AddItem rsLoad.Fields("RealName") rsLoad.MoveNext Wend End If For i = 0 To cboUserName.ListCount - 1 If cboUserName.List(i) = strLogin Then cboUserName.ListIndex = i Exit For Else cboUserName.ListIndex = -1 End If Next怎么不行啊.
if 没有其中的值 then combo.listindex=-1
else combo.listindex=i:exit for
next
if strLogin<>cboLogin.list(i) then
cboLogin.listindex=-1
else
cboLogin.listindex=i
exit for
end if
next
Dim n As Integer
INIFileName$ = App.Path & "\" & strCFG_FileNamen = GetPrivateProfileString("INFO", "LastLogin", "", strLogin, Len(strLogin), INIFileName)
strLogin = Left(strLogin, n) '读取INI里面最后登陆者的名字
Call objConnDim rsLoad As New ADODB.Recordset
sqlLoad$ = "SELECT RealName,UserName FROM ADMIN ORDER BY UserName ASC"
rsLoad.Open sqlLoad, conn, 1, 1
If cboUserName.ListCount <> rsLoad.RecordCount Then
cboUserName.Clear
While rsLoad.EOF = False
cboUserName.AddItem rsLoad.Fields("RealName")
rsLoad.MoveNext
Wend
End If
For i = 0 To cboUserName.ListCount - 1
If cboUserName.List(i) = strLogin Then
cboUserName.ListIndex = i
Exit For
Else
cboUserName.ListIndex = -1
End If
Next怎么不行啊.