求VB高手解答下面代码, 5
PrivateSubForm_Load()-------/调用一个事件Load/Move(Mainfrm.Width-Width)/2,(Mainfrm.ScaleHei...
Private Sub Form_Load()-------/调用一个事件Load/
Move (Mainfrm.Width - Width) / 2, (Mainfrm.ScaleHeight - Height) / 2
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset------/错误来源/
Dim sql As String
On Error GoTo ErrMsg
Set con = New ADODB.Connection -------/ set 给对象赋值 /
Set rs = New ADODB.Recordset
If Not con.State = adStateOpen Then -------- / if not 循环/
con.ConnectionString = sqlcon
con.Open
End If
sql = "select sum(spk_num) as bpk_num,pro_bigpack,pro_smallpack,pro_type,pro_jweight,pro_mweight,BPK_Color,BPK_Date from v_BPK_inf where BPK_ID='" & bpkno & "' GROUP BY BPK_ID, pro_bigpack,pro_smallpack,pro_type,BPK_Color,BPK_Date,pro_jweight,pro_mweight"
rs.Open sql, con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then ---------/EOF 文件结束符/
Me.lbltype.Caption = rs.Fields("pro_type")
Me.lblnum.Caption = rs.Fields("bpk_num")
Me.lbljweight.Caption = rs.Fields("pro_jweight")
'Me.lblmweight.Caption = rs.Fields("pro_mweight")
If (rs.Fields("pro_mweight") <> Null) Then
Me.lblmweight.Caption = rs.Fields("pro_mweight")
Else
Me.lblmweight.Caption = ""
End If
Me.BarcodeX1.Caption = bpkno
Me.BarcodeX1.Title = bpkno & "-" & rs.Fields("BPK_color")
End If
rs.Close
sql = "select bpk_jweight,bpk_mweight from bpk_no where BPK_ID='" & bpkno & "'"
rs.Open sql, con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
'If rs.Fields("bpk_jweight") <> 0 And rs.Fields("bpk_mweight") <> 0 Then
' Me.lbljweight.Caption = rs.Fields("bpk_jweight")
'Me.lblmweight.Caption = rs.Fields("bpk_mweight")
'End If
If rs.Fields("bpk_jweight") <> 0 Then
Me.lbljweight.Caption = rs.Fields("bpk_jweight")
Else
Me.lbljweight.Caption = ""
End If
If rs.Fields("bpk_mweight") <> 0 Then
Me.lblmweight.Caption = rs.Fields("bpk_mweight")
Else
Me.lblmweight.Caption = ""
End If
End If
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
Exit Sub
ErrMsg:
MsgBox Err.Description, vbCritical, "Error"
End Sub 展开
Move (Mainfrm.Width - Width) / 2, (Mainfrm.ScaleHeight - Height) / 2
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset------/错误来源/
Dim sql As String
On Error GoTo ErrMsg
Set con = New ADODB.Connection -------/ set 给对象赋值 /
Set rs = New ADODB.Recordset
If Not con.State = adStateOpen Then -------- / if not 循环/
con.ConnectionString = sqlcon
con.Open
End If
sql = "select sum(spk_num) as bpk_num,pro_bigpack,pro_smallpack,pro_type,pro_jweight,pro_mweight,BPK_Color,BPK_Date from v_BPK_inf where BPK_ID='" & bpkno & "' GROUP BY BPK_ID, pro_bigpack,pro_smallpack,pro_type,BPK_Color,BPK_Date,pro_jweight,pro_mweight"
rs.Open sql, con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then ---------/EOF 文件结束符/
Me.lbltype.Caption = rs.Fields("pro_type")
Me.lblnum.Caption = rs.Fields("bpk_num")
Me.lbljweight.Caption = rs.Fields("pro_jweight")
'Me.lblmweight.Caption = rs.Fields("pro_mweight")
If (rs.Fields("pro_mweight") <> Null) Then
Me.lblmweight.Caption = rs.Fields("pro_mweight")
Else
Me.lblmweight.Caption = ""
End If
Me.BarcodeX1.Caption = bpkno
Me.BarcodeX1.Title = bpkno & "-" & rs.Fields("BPK_color")
End If
rs.Close
sql = "select bpk_jweight,bpk_mweight from bpk_no where BPK_ID='" & bpkno & "'"
rs.Open sql, con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
'If rs.Fields("bpk_jweight") <> 0 And rs.Fields("bpk_mweight") <> 0 Then
' Me.lbljweight.Caption = rs.Fields("bpk_jweight")
'Me.lblmweight.Caption = rs.Fields("bpk_mweight")
'End If
If rs.Fields("bpk_jweight") <> 0 Then
Me.lbljweight.Caption = rs.Fields("bpk_jweight")
Else
Me.lbljweight.Caption = ""
End If
If rs.Fields("bpk_mweight") <> 0 Then
Me.lblmweight.Caption = rs.Fields("bpk_mweight")
Else
Me.lblmweight.Caption = ""
End If
End If
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
Exit Sub
ErrMsg:
MsgBox Err.Description, vbCritical, "Error"
End Sub 展开
展开全部
可以加我QQ,我给你带注释的原码。在这上面敲字太累了。。
追问
好的啊, 你QQ是多少?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim rs As New ADODB.Recordset
然后直接用rs操作不用SET了
然后直接用rs操作不用SET了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
什么破代码啊,注释那么少,一看就没工作经验
追问
我是求解释这个代码
这个注释少我才没看明白嘛
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询