| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 521 人关注过本帖
标题:[求助]排课系统中如何扩大可输入科目?
只看楼主 加入收藏
zhongxq123
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-6-12
收藏
 问题点数:0 回复次数:1 
[求助]排课系统中如何扩大可输入科目?

  这是我进行练习的教师排课系统中的开设课程代码设置.但只能限定10门课,怎样才能扩大可输入的科目? 请高手指教一下!多谢了!(我已经试过把所有的9改为13,可是出错信息显示实时错误'340',控件数组元素'10'不存在.)
Option Explicit
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim str(13) As String

'Dim strSql As String

Private Sub cn_Click(Index As Integer)
'On Error GoTo ex:
Dim lcnt As Integer
Dim strTxt As String

Select Case Index
Case 0:
CanSave (True)

Case 1:
con.Execute ("delete * from subject")

For lcnt = 0 To 13
strTxt = Trim$(LTrim$(Txt(lcnt).Text))
If Len(strTxt) > 0 Then
rs.AddNew
rs!csjname = strTxt
rs.Update
End If
Next lcnt
CanSave (False)
Case 2:
For lcnt = 0 To 13
Txt(lcnt) = str(lcnt)
Next lcnt
CanSave (False)

End Select


Exit Sub

ex:
MsgBox "database error", vbOKOnly + vbExclamation, "error"

End Sub

Private Sub Form_Load()
'strSql = "insert into subject values( '"
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset

Call clearTxt
CanSave (False)

con.Open "provider=Microsoft.Jet.OLEDB.4.0; data source= " & App.Path & "\dataUse.mdb"
rs.Open "select * from subject", con, adOpenStatic, adLockOptimistic
Call displayInfo

End Sub
Private Sub CanSave(bSave As Boolean)
Frame1.Enabled = bSave
cn(1).Enabled = bSave
cn(2).Enabled = bSave

cn(0).Enabled = Not bSave

End Sub
Private Sub displayInfo()
rs.MoveFirst
Dim lcnt As Integer
lcnt = 0
While (Not rs.EOF And lcnt < 14)

Txt(lcnt).Text = rs!csjname
str(lcnt) = Txt(lcnt).Text

lcnt = lcnt + 1
rs.MoveNext

Wend

End Sub
Private Sub clearTxt()
Dim lcnt As Integer
For lcnt = 0 To 13
Txt(lcnt).Text = ""
Next lcnt

End Sub

Private Sub Form_Unload(Cancel As Integer)
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing

End Sub

搜索更多相关主题的帖子: 课系统 科目 Dim String Integer 
2007-06-24 21:10
zhongxq123
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-6-12
收藏
得分:0 

有没有人理我,请高手帮忙呀!

2007-06-26 00:52
快速回复:[求助]排课系统中如何扩大可输入科目?
数据加载中...
 
   



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

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