| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1282 人关注过本帖
标题:这个用户自定义类型在那呀,请各位大师指教
只看楼主 加入收藏
vb菜鸟
Rank: 1
等 级:新手上路
帖 子:61
专家分:0
注 册:2005-4-26
收藏
 问题点数:0 回复次数:4 
这个用户自定义类型在那呀,请各位大师指教

各位大师: 小妹很喜欢编程,可是一至没有带,现在还是一只小菜鸟,希望名们师指教指教小妹,小妹现在正照着书上做一图书管理系统,可还是有很多代码看不懂,界面好图所示,代码如下, Private Sub chkquery_click() If chkquery.Value = 1 Then txtquerybookid.Enabled = True Else txtquerybookid.Enabled = False End If

End Sub 'Private Declare Function OSWinHelp% Lib "user32" Alias "WinHelpA" (ByVal hwnd&, ByVal HelpFile$, ByVal wCommand%, dwData As Any) 'End Sub

Private Sub cmdlendbook_Click() If txtreaderid.Text <> "" Then '如果"读者编号"不为空 If lblremain.Caption <> "0" Then '判断"还允许借出册数"是否已借满 Set g_rs = g_db.openrecordset("leninfo", dbopentable) '??????????????????? With g_rs .AddNew .Fields("读者编号") = txtreaderid.Text .Fields("图书编号") = txtbookid.Text .Fields("借阅日期") = dtplenddate.Value .Update End With Set g_rs = Nothing g_strSql = "select * from bookinfo where 图书编号='" & txtbookid.Text & "'" Set g_rs = g_db.openrecordset(g_strSql) g_rs.EditMode g_rs.Fields("是否借出").Value = True g_rs.Update Set g_rs = noting MsgBox "借出完毕!", vbOKOnly, "提示" txtbookid.Text = "" txtbookname.Text = "" txtbookprice.Text = "" txtbookleibie.Text = "" txtbookconcern.Text = "" txtbookpage.Text = "" initdatagrid (False) Else MsgBox "您的书已经借满,不能再借!", vbOKOnly, "提示" End If Else MsgBox "请先输入读者编号!", vbOKOnly, "提示" End If End Sub

Private Sub cmdok_Click() g_strSql = "select * from lentinfo where 图书编号='" & txtbookidrenew.Text & "'and 读者编号='" & txtreaderidrenew.Text & "'and 借阅日期=#" & txtlenddate.Text & "#" Set g_rs = g_db.openrecordset(g_strSql) g_rs.EditMode Set g_rs = noting Adodc1.recordset.Update MsgBox "续借完成", vbOKOnly, "提示"

End Sub

Private Sub cmdreturn_Click() g_strSql = "select * from lentinfo where 图书编号='" & txtbookidreturn.Text & "'and 读者编号='" & txtreaderidreturn.Text & "'and 借阅日期=#" & txtlenddatereturn.Text & "#" Set g_rs = g_db.openrecordset(g_strSql) g_rs.EditMode g_rs.Fields("还书日期").Value = txtreturndate.Text g_rs.Fields("罚款金额").Value = txtfakuan.Text g_rs.Update Set g_rs = noting g_strSql = "select * from bookinfo where 图书编号='" & txtbookerturn.Text & "'" Set g_rs = g_db.openrecordset(g_strSql) g_rs.EditMode g_rs.Fields("是否借出").Value = False g_rs.Update Set g_rs = noting txtbookerturn.Text = "" txtbooknamereturn.Text = "" txtpricereturn.Text = "" txtbookleibeireturn.Text = "" txtbookpagereturn.Text = "" txtreadernamereturn.Text = "" txtreaderidreturn.Text = "" txtday.Text = "" txtdaycount.Text = "" MsgBox "归还完毕!", vbOKOnly, "提示"

End Sub

Private Sub Form_Load() Me.Left = GetSetting(App.Title, "Settings", "MainLeft", 1000) Me.Top = GetSetting(App.Title, "Settings", "MainTop", 1000) Me.Width = GetSetting(App.Title, "Settings", "MainWidth", 6500) Me.Height = GetSetting(App.Title, "Settings", "MainHeight", 6500) dtplenddate.Value = Date dtplenddatechange.Value = Date Set g_ws = dbengine.workspaces(0) Set g_db = g_ws.opendatabase(App.Path + "\图书馆查询管理系统.mdb") End Sub

Private Sub Form_Unload(Cancel As Integer) Dim i As Integer

'close all sub forms For i = Forms.Count - 1 To 1 Step -1 Unload Forms(i) Next If Me.WindowState <> vbMinimized Then SaveSetting App.Title, "Settings", "MainLeft", Me.Left SaveSetting App.Title, "Settings", "MainTop", Me.Top SaveSetting App.Title, "Settings", "MainWidth", Me.Width SaveSetting App.Title, "Settings", "MainHeight", Me.Height End If g_db.Close Set g_db = noting g_ws.Close Set g_ws = noting End Sub

Private Sub mnubookmanage_Click() frmbookquery.Show

End Sub

Private Sub mnubookquery_Click() frmlendquery.Show

End Sub

Private Sub mnusetbasic_Click() frmsetbasic.Show

End Sub

Private Sub mnusetbook_Click() frmsetbook.Show

End Sub

Private Sub tbToolBar_ButtonClick(ByVal Button As MSComctlLib.Button) On Error Resume Next Select Case Button.Key Case "新建图书信息" frmaddnew.Show Case "图书管理" frmbookmange.Show Case "图书查找" '应做:添加 '图书查找' 按钮代码。 MsgBox "添加 '图书查找' 按钮代码。" Case "打印" frmbookquery.Show Case "剪切" '应做:添加 '剪切' 按钮代码。 MsgBox "添加 '剪切' 按钮代码。" Case "复制" '应做:添加 '复制' 按钮代码。 MsgBox "添加 '复制' 按钮代码。" Case "粘贴" '应做:添加 '粘贴' 按钮代码。 MsgBox "添加 '粘贴' 按钮代码。" Case "退出" End End Select End Sub

Private Sub mnuHelpAbout_Click() MsgBox "版本 " & App.Major & "." & App.Minor & "." & App.Revision End Sub

Private Sub mnuHelpSearchForHelpOn_Click() Dim nRet As Integer

'如果这个工程没有帮助文件,显示消息给用户 '可以在“工程属性”对话框中为应用程序设置帮助文件 If Len(App.HelpFile) = 0 Then MsgBox "无法显示帮助目录,该工程没有相关联的帮助。", vbInformation, Me.Caption Else

On Error Resume Next nRet = OSWinHelp(Me.hWnd, App.HelpFile, 261, 0) If Err Then MsgBox Err.Description End If End If

End Sub

Private Sub mnuHelpContents_Click() Dim nRet As Integer

'如果这个工程没有帮助文件,显示消息给用户 '可以在“工程属性”对话框中为应用程序设置帮助文件 If Len(App.HelpFile) = 0 Then MsgBox "无法显示帮助目录,该工程没有相关联的帮助。", vbInformation, Me.Caption Else On Error Resume Next nRet = OSWinHelp(Me.hWnd, App.HelpFile, 3, 0) If Err Then MsgBox Err.Description

End If End If End Sub Private Sub txtbookid_keypress(KeyAscii As Integer) If KeyAscii = "13" And txtreaderid.Text <> "" And txtbookid.Text <> "" Then g_strSql = "select bookinfo.书籍名称,bookinfo.书籍价格,bookinfo.出版社,bookinfo.书籍页码," _ & "bookinfo.是否借出,booktype.书籍类别 from bookinfo,booktype where 书籍编号='" & txtbookid.Text & "'" _ & "and bookinfo.类别代码=booktype.类别代码" Set g_rs = g_dbopenrecordset(g_strSql) If Not g_rs.EOF Then txtbookname.Text = g_rs!书籍名称 txtbookprice.Text = g_rs!书籍价格 txtbookleibie.Text = g_rs!书籍类别 txtbookconcern.Text = g_rs!出版社 txtbookpage.Text = g_rs!书籍页码 If g_rs!是否借出 = True Then MsgBox "此书已经借出,请选择其它书籍!", vbOKOnly, "提示" cmdlendbook.Enabled = False Else cmdlendbook.Enabled = True End If Else MsgBox "没有该书信息!", vbOKOnly, "提示" txtbookname.Text = "" txtbookprice.Text = "" txtbookleibie.Text = "" txtbookconcern.Text = "" txtbookpage.Text = "" End If Set g_rs = noting ElseIf KeyAscii = "13" And txtbookerturn.Text Then strsql = "select lendinfo.读者编号,readerinfo.读者姓名,lentinfo.书籍编号,bookinfo.书籍价格," _ & "bookinfo.书籍名称,bookinfo.书籍页码,lentnfo.借书日期,booktype.书籍编号,booktype.借出天数" _ & "from raederinfo,bookinfo,lentinfo,booktype where readerinfo.读者编号=lentinfo.读者编号" _ & "and bookinfo.书籍编号=lentinfo.书籍编号 and bookinfo.书籍编号='" & txtbookerturn.Text & "'" _ & "and bookinfo.类别代码=booktype.类别代码" g_strSql = strsql Set g_rs = g_db.openrecordset(g_strSql) If Not g_rs.EOF Then cmdlendbook.Enabled = True txtbooknamereturn.Text = g_rs!书籍名称 txtpricereturn.Text = g_rs!书籍价格 txtbookleibeireturn.Text = g_rs!书籍类别 txtbookpagereturn.Text = g_rs!书籍页码 txtreaderidreturn.Text = g_rs!读者编号 txtreadernamereturn.Text = g_rs!读者姓名 txtlenddatereturn.Text = g_rs!借出日期 txtday.Text = g_rs!借出天数 txtreturndate.Text = Date txtfactday.Text = CStr(Date - g_rs!借书日期) If CInt(txtfactday.Text) - CInt(txtday.Text) > 0 Then txtdaycount.Text = CStr(CInt(txtdaycount.Text) - CInt(txtreturndate.Text)) Else txtdaycount.Text = "0" End If Set g_rs = noting g_strSql = strsql Set g_rs = g_db.openrecordset("select * from basicset") txtfakuan.Text = g_rs!罚款 * CInt(txtdaycount.Text) Set g_rs = noting cmdreturn.Enabled = True Else Set g_rs = noting MsgBox "没有该书信息", vbOKOnly, "提示" txtbooknamereturn.Text = "" txtpricereturn.Text = "" txtbookleibeireturn.Text = "" txtbookpagereturn.Text = "" txtreaderidreturn.Text = "" txtreadernamereturn.Text = "" txtlenddatereturn.Text = "" txtday.Text = "" txtreturndate.Text = "" txtfactday.Text = "" txtdaycount.Text = "" cmdreturn.Enabled = False End If ElseIf KeyAscii = "13" And txtbookerturn.Text = "" Then MsgBox "请先输入图书编号!", vbOKOnly, "提示" End If End Sub Public Function initdatagrid(binrenew As Boolean) Dim strdatasource As Integer Dim strreaderid As String Dim intcount As Integer If binrenew = False Then strreaderid = txtreaderid.Text Else strreaderid -txtreaderidrenew.Text End If strdatesource = "select lentinfo.读者编号,readerinfo.读者姓名,lentinfo.书籍编号," _ & "bookinfo.书籍名称,booktype.书籍类别,bookinfo.出版社,bookinfo.书籍页码,lentinfo.借书日期," _ & "lentinfo.还书日期,lentinfo.超出天数,lentinfo.罚款金额 from readerinfo,bookinfo,lentinfo,booktyep" _ & "where readerinfo.读者编号=lentinfo.读者编号 and bookinfo.书籍编号=lentinfo.书籍编号 and" _ & "lentinfo.读者编号='" & strreaderid & "' and booktype.类别代码=bookinfo.类别代码 and lentinfo.还书日期 is null" Adodc1.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\图书馆查询管理系统.mdb;persist security info=false" Adodc1.CursorLocation = adUseClient Adodc1.CommandType = adCmdText Adodc1.RecordSource = strdatasoure Adodc1.Refresh If blnrenew = False Then Set dtgrdLendBook.DataSource = Adodc1 dtgrdLendBook.Refresh lbllendcount.Caption = "所借图书:" + CStr(Adodc1.recordset.RecordCount) g_strSql = "select *from basicset" Set g_rs = g_db.openrecordset(g_strSql) intcount = g_rs!借出册数 - Adodc1.recordset.RecordCount lblremain.Caption = CStr(intcount) Else Set dtgrdLendBookRenew.DataSource = Adodc1 dtgrdLendBookRenew.Refresh End If End Function Private Sub txtreaderidrenew_KeyPress(KeyAscii As Integer) If KeyAscii = "13" And txtreaderidrenew.Text <> "" Then g_strSql = "select * from readerinfo where 读者编号='" & txtreaderidrenew.Text & "'" Set g_rs = g_db.openrecordset(g_strSql) If Not g_rs.EOF Then txtreadernamerenew.Text = g_rs!读者姓名 initdatagrid (True) Else MsgBox "没有该读者信息!", vbOKOnly, "提示" txtreadernamerenew.Text = "" cmdok.Enabled = False End If Set g_rs = noting ElseIf KeyAscii = "13" And txtreaderidrenew.Text = "" Then MsgBox "请先输入读者编号!", vbOKOnly, "提示" cmdok.Enabled = False End If End Sub 模块中的代码如下 Public g_ws As Workspace Public g_db As Database Public g_rs As Recordset Public g_strSql As String 运行时总是提示用户定义类型wordspace,database,recordset,未定义,在它的源码中也找不到那几个东东是在那定义的,但它的源码也可以运行,真是气死我也,求各位大师帮我出出这口恶气,谢谢,qq:94465584

搜索更多相关主题的帖子: 定义 大师 类型 用户 指教 
2005-04-30 17:14
caoyuanbuluo
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2005-4-21
收藏
得分:0 
      从上边可以看出你用的是DAO(Data Access Object)模型。出现你所说的问题,我认为可能是你没有引用这模型。解决办法:单击菜单“工程”——“引用”,将弹出“引用”对话框,找到“Microsoft DAO Library”(我记不清,大致上就是这个),选种它,并“确定”。然后你再试试。
      DAO是一种相对较老的模型,现在的.NET对它已经不再支持。建议你学习ADO编程技术。
2005-04-30 21:21
vb菜鸟
Rank: 1
等 级:新手上路
帖 子:61
专家分:0
注 册:2005-4-26
收藏
得分:0 
      这位高人你真历害,和源码比较我发现我没有引用microsoft dao 3.6 object library,mcirosoft data binding callertion,microsoft data formatting object library,这三个模型,现在问题虽然搞定.非常感谢,但不知那些模型和一些部件有什么功能和怎么用,不知这位高人有没有这方面的网络资源借小妹学习习,还有现在开发语言很多,不知该学那一个好,请给小妹指条明路吧,再次非常感谢,

2005-05-02 09:05
vb菜鸟
Rank: 1
等 级:新手上路
帖 子:61
专家分:0
注 册:2005-4-26
收藏
得分:0 
各位大师: 还是上面一段代码,运行时出现下面几句都出现"类型不匹配"的错误,请各位大师帮看看,谢谢! Set g_rs = g_db.openrecordset(g_strSql) Set g_rs = g_db.openrecordset("leninfo", dbopentable) Set g_rs = g_db.openrecordset("select * from basicset") 模块中变量定义如下 Public g_ws As Workspace Public g_db As Database Public g_rs As Recordset Public g_strSql As String

2005-05-02 21:03
vb菜鸟
Rank: 1
等 级:新手上路
帖 子:61
专家分:0
注 册:2005-4-26
收藏
得分:0 
怎么没人回,各位大师都去那了,是不是我说的不清楚,

2005-05-07 16:57
快速回复:这个用户自定义类型在那呀,请各位大师指教
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025135 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved