求助!!关于两条代码

gongcqj 2008-03-31 01:17:06
Private Sub comprint_Click() '打印住宿登记单据
Printer.Height = 8000: Printer.Width = 8000
Printer.CurrentX = 1100: Printer.CurrentY = 300
Printer.FontSize = 12
Printer.Print " 住宿证 "
Dim A, B, c, D As Integer
A = 100: B = 500: c = 4800: D = 400
Printer.FontSize = 10
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print Date & " " & Time & " NO." & bh.Text
B = B + D
Printer.Line (A, B + 100)-(c, B + 100)
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "姓名:" & ZSDJ(0).Text
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "房间号:" & DBCombo1.Text
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "押金:" & Format(ZSDJ(10).Text, "0.00")
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print Combo2.Text & ":" & ZSDJ(8).Text & "%"
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "补交日期: " & DTP2.Value
B = B + D
Printer.Line (A, B + 100)-(c, B + 100)
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "操作员: " & czy.Text & " 欢迎光临"
Printer.EndDoc
End Sub

运行后出现‘482’打印机错误,请问语句哪里有错?







有一command控件组,其caption与房间号相同,当按钮为绿色表示无人,蓝色为有人,代码如下:
Private Sub Form_Activate()
Dim i As Integer '定义一个整型变量
Dim criteria As String '定义一个字符串变量
Dim mydb1 As Database '定义数据库
Dim myrs1 As Recordset '定义字段
Dim myrs2 As Recordset
Dim myrs3 As Recordset
Set mydb1 = Workspaces(0).OpenDatabase(App.Path & "\kfgl.mdb") '定义数据环境
Set myrs1 = mydb1.OpenRecordset("kf", dbOpenSnapshot) '定义数据表
'入住房间查询
sql = "select * from kf where kf.房态 like " + Chr(34) + "入住" + Chr(34) + ""
Set myrs2 = mydb1.OpenRecordset(sql)
'维修房间查询
sql = "select * from kf where kf.房态 like " + Chr(34) + "维修" + Chr(34) + ""
Set myrs3 = mydb1.OpenRecordset(sql)

For i = 0 To 139 '房态显示
criteria = "房间号 ='" & Command1(i).Caption & "'"
myrs1.FindFirst criteria
If myrs1.NoMatch Then
Else
If myrs1.Fields("房态") = "空房" Then Command1(i).BackColor = RGB(0, 255, 0) '空房
If myrs1.Fields("房态") = "入住" Then Command1(i).BackColor = RGB(0, 0, 255) '入住
If myrs1.Fields("房态") = "维修" Then Command1(i).BackColor = RGB(255, 255, 0) '维修
End If
Next i
表kf的字段“标志”也可判断房间是否有人住,0为无人,1为有人。
现在想实现在command的单击事件时,按绿色按钮调用窗体1,蓝色调用窗体2,代码该如何写?

...全文
92 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
没遇到过这种情况.
回复
舉杯邀明月 2008-04-01
不好意思: 十六进制数据前忘了加 &H

lBgColor = Command1(i).BackColor
if (lBgColor = &HFF0000) then
Form2.show 1
elseif (lBgColor = &HFF00) then
Form1.show 1
else
MsgBox "维修状态", 64, "信息"
endif
回复
gongcqj 2008-03-31
按照二楼的代码,运行出来后不论按什么颜色的按钮都只跳出维修信息框啊.
回复
舉杯邀明月 2008-03-31
没打印机,这个问题不好深究。

第二个问题:
dim lBgColor&

lBgColor = Command1(i).BackColor
if (lBgColor = FF0000) then
Form2.show 1
elseif (lBgColor = FF00) then
Form1.show 1
else
MsgBox "维修状态", 64, "信息"
endif

回复
东方之珠 2008-03-31
Run-time error '482'的提示信息应该是"Printer Error."。出现 "Printer Error"错误,通常是打印机联机不当,如未开打印机,或未按下联机键。
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7489

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2008-03-31 01:17
社区公告
暂无公告