vb学生管理系统源代码部分代码PublicUserNameAsStringPublictxtSQLAsString'usetostorerecordSQLsentencePublicdreamAsADODB.Recordset'usetostorerecordobjectPublicMsgtextAsString'用来存放返回信息PublicOKAsBoolean''PublicdbAsStringPublicSubhighlight()WithScreen.ActiveFormIf(TypeOf.ActiveControlIsTextBox)Then.ActiveControl.SelStart=0.ActiveControl.SelLength=Len(.ActiveControl)EndIfEndWithEndSubSubMain()'DimLoginAsNewLogin'Login.ShowvbModal'fNotLogin.OKThen'LoginFailedsoexitapp'End'EndIf'Unloadstudentmdi'Setlogin=Newloginlogin.ShowEndSubPublicFunctionconnectstring()AsStringconnectstring="Provider=Microsoft.jet.OLEDB.3.51;Datasource=f:\schoolgroup\school.mdb"EndFunctionPublicFunctionExecuteSQL(ByValSQLAsString,MsgstringAsString)AsADODB.RecordsetDimcnnAsADODB.ConnectionDimrstAsADODB.RecordsetDimsTokens()AsStringOnErrorGoToExecuteSQL_ErrorsTokens=Split(SQL)Setcnn=NewADODB.Connectioncnn.OpenconnectstringIfInStr("INSERT,DELETE,UPDATE",UCase$(sTokens(0)))Thencnn.ExecuteSQLMsgstring=sTokens(0)&"querysuccessful"ElseSetrst=NewADODB.Recordsetrst.OpenTrim(SQL),cnn,adOpenKeyset,adLockOptimisticSetExecuteSQL=rstMsgstring="查询到"&rst.RecordCount&"条记录"EndIfexecuteSQL_exit:Setrst=NothingSetcnn=NothingExitFunctionExecuteSQL_Error:Msgstring="查询错误:"&err.DescriptionResumeexecuteSQL_exitEndFunctionPublicFunctionTesttxt(txtAsString)AsBooleanIfTrim(txt)=""ThenTesttxt=FalseElseTesttxt=TrueEndIfEndFunction
1