亲们,帮我看一下vb代码吧,谢谢
Private Sub USEID_KeyPress(KeyAscii As Integer)On Error Resume Next
Dim IRow As Long, Icol As Long, ISum As Single, SSum As String, i As Integer, SubSF As Single, TempSF As Single
If KeyAscii = 13 Then
SumSF = 0: VSgrid.Rows = 3
STRZH = USEID.Text
ADOdb.ConnectionString = sConnect
ADOdb.RecordSource = "SELECT Distinct Area.AreaName,Data.AccountID, Data.SBInfoID,Data.sYear, Data.sMonth,Data.UnitPrice,Data.SSUNFL,Client.UserName,Data.ID,Data.Typename,Client.userJFtype" _
+ " FROM (Client INNER JOIN Area ON Client.AreaID = Area.AreaID) INNER JOIN Data ON Client.UserAccount = Data.AccountID" _
+ " WHERE Data.AccountID='" + STRZH + " 'And data.syear='" + TXTyear.Text + "' and data.smonth='" + TXTyue.Text + "'" _
+ " Order By Data.AccountID,Data.SBInfoID,data.syear,data.smonth"
ADOdb.Refresh
PPrice = ADOdb.Recordset.Fields("UnitPrice")
If ADOdb.Recordset.RecordCount <= 0 Then
'MsgBox "用户编号错误!", vbDefaultButton1, "请查对"
Exit Sub
Else
ORidRsCount = ADOdb.Recordset.RecordCount
ReDim ORidID(2 To 2 + ORidRsCount - 1)
ReDim ORidTypename(2 To 2 + ORidRsCount - 1)
ReDim ORidWSCLL(2 To 3 + ORidRsCount - 1)
ReDim ORidWSCLprice(2 To 2 + ORidRsCount - 1)
VSgrid.Rows = VSgrid.Rows + ORidRsCount - 1
For Icol = 0 To VSgrid.Cols - 1
VSgrid.Row = 0: VSgrid.Col = Icol
Select Case Icol
Case 1
VSgrid.TextMatrix(0, Icol) = Left(ADOdb.Recordset.Fields("AreaName"), 2)
VSgrid.CellAlignment = flexAlignCenterCenter
Case 3
VSgrid.TextMatrix(0, Icol) = ADOdb.Recordset.Fields("AccountID")
VSgrid.CellAlignment = flexAlignCenterCenter
Case 5
VSgrid.TextMatrix(0, Icol) = ADOdb.Recordset.Fields("UserName")
VSgrid.CellAlignment = flexAlignCenterCenter
Case 7
VSgrid.TextMatrix(0, Icol) = str(TXTyear.Text) + "." + str(TXTyue.Text)
VSgrid.CellAlignment = flexAlignCenterCenter
Case 9
VSgrid.TextMatrix(0, Icol) = Space(2) + OperName
VSgrid.CellAlignment = flexAlignCenterCenter
End Select
Next
ADOdb.Recordset.MoveFirst
IRow = 2: SumSF = 0
If ADOdb.Recordset.Fields("TypeName") <> "大客户" Then
With VSgrid
.MergeRow(IRow) = True
Do While Not ADOdb.Recordset.EOF()
.TextMatrix(IRow, 0) = UCase(ADOdb.Recordset.Fields("SBInfoID"))
AdoTemp.RecordSource = "SELECT MIN(BeginNum) AS 起始读数, MAX(EndNum) AS 终止读数 From data Where sYear=" + TXTyear.Text + " And Smonth=" + TXTyue.Text + " And SBInfoID='" + .TextMatrix(IRow, 0) + "'"
AdoTemp.Refresh
.TextMatrix(IRow, 1) = AdoTemp.Recordset.Fields("起始读数")
If AdoTemp.Recordset.Fields("起始读数") = AdoTemp.Recordset.Fields("终止读数") Then
.TextMatrix(IRow, 2) = " " + str(AdoTemp.Recordset.Fields("终止读数")) + " "
Else
.TextMatrix(IRow, 2) = AdoTemp.Recordset.Fields("终止读数")
End If
.TextMatrix(IRow, 3) = GETcheckSsun(.TextMatrix(IRow, 0), TXTyear.Text, TXTyue.Text)
.TextMatrix(IRow, 4) = ADOdb.Recordset.Fields("Typename")
.TextMatrix(IRow, 5) = (.TextMatrix(IRow, 2)) - (.TextMatrix(IRow, 1)) - ADOdb.Recordset.Fields("userJFtype") + (.TextMatrix(IRow, 3))
If (.TextMatrix(IRow, 5)) < 0 Then
.TextMatrix(IRow, 5) = 0
End If
.TextMatrix(IRow, 6) = ADOdb.Recordset.Fields("UnitPrice")
.TextMatrix(IRow, 7) = Trim(str(ADOdb.Recordset.Fields("SSUNFL") * 100)) + "%"
TempSF = (.TextMatrix(IRow, 6)) * (1 - ADOdb.Recordset.Fields("SSUNFL")) * (.TextMatrix(IRow, 5))
.TextMatrix(IRow, 8) = Round(TempSF, 2)
.TextMatrix(IRow, 9) = Round(TempSF, 2)
SumSF = SumSF + (.TextMatrix(IRow, 9))
ORidID(IRow) = ADOdb.Recordset.Fields("ID")
ORidTypename(IRow) = ADOdb.Recordset.Fields("TypeName")
ORidWSCLL(IRow) = ADOdb.Recordset.Fields("SSUNratio")
ADOdb.Recordset.MoveNext
VSgrid.MergeRow(IRow) = True
IRow = IRow + 1
Loop
End With
Else
AdoMass.ConnectionString = sConnect
AdoMass.RecordSource = "SELECT Distinct Area.AreaName, Client.UserAccount, Client.UserName, Data.sYear, Data.sMonth, Data.SBInfoID, PayPercent.ID, PayPercent.Sprice, PayPercent.Spercent, SSUNInfo.SSUNFL,Client.userJFtype" _
+ " FROM ((PayPercent INNER JOIN (Data INNER JOIN Client ON Data.AccountID=Client.UserAccount) ON PayPercent.UserAccount=Data.AccountID) INNER JOIN Area ON Client.AreaID=Area.AreaID) INNER JOIN SSUNInfo ON Client.SSUNID=SSUNInfo.SSUNID" _
+ " WHERE (Data.AccountID='" + STRZH + " ') And data.syear=" + TXTyear.Text + " and data.smonth=" + TXTyue.Text _
+ " Order By data.syear,data.smonth,Data.SBInfoID"
AdoMass.Refresh
Debug.Print AdoMass.Recordset.RecordCount
With VSgrid
ReDim ORidID(2 To 2 + AdoMass.Recordset.RecordCount - 1)
ReDim ORidTypename(2 To 2 + AdoMass.Recordset.RecordCount - 1)
ReDim ORidWSCLL(2 To 3 + AdoMass.Recordset.RecordCount - 1)
ReDim ORidWSCLprice(2 To 2 + AdoMass.Recordset.RecordCount - 1)
.Rows = 2 + AdoMass.Recordset.RecordCount
AdoMass.Recordset.MoveFirst
Do While AdoMass.Recordset.EOF() = False
.TextMatrix(IRow, 0) = UCase(AdoMass.Recordset.Fields("SBInfoID"))
AdoTemp.RecordSource = "SELECT MIN(BeginNum) AS 起始读数, MAX(EndNum) AS 终止读数 From data Where sYear=" + TXTyear.Text + " And Smonth=" + TXTyue.Text + " And SBInfoID='" + .TextMatrix(IRow, 0) + "'"
AdoTemp.Refresh
.TextMatrix(IRow, 1) = AdoTemp.Recordset.Fields("起始读数")
If AdoTemp.Recordset.Fields("起始读数") = AdoTemp.Recordset.Fields("终止读数") Then
.TextMatrix(IRow, 2) = " " + str(AdoTemp.Recordset.Fields("终止读数")) + " "
Else
.TextMatrix(IRow, 2) = AdoTemp.Recordset.Fields("终止读数")
End If
.TextMatrix(IRow, 3) = GETcheckSsun(.TextMatrix(IRow, 0), (TXTyear.Text), (TXTyue.Text))
.TextMatrix(IRow, 4) = AdoMass.Recordset.Fields("ID")
.TextMatrix(IRow, 5) = Round((Val(.TextMatrix(IRow, 2)) - (.TextMatrix(IRow, 1)) - AdoMass.Recordset.Fields("userJFtype") + (.TextMatrix(IRow, 3))) * AdoMass.Recordset.Fields("Spercent"), 2)
If (.TextMatrix(IRow, 5)) < 0 Then
.TextMatrix(IRow, 5) = 0
End If
.TextMatrix(IRow, 6) = AdoMass.Recordset.Fields("sPrice")
.TextMatrix(IRow, 7) = Trim(str(ADOdb.Recordset.Fields("SSUNFL") * 100)) + "%"
TempSF = (.TextMatrix(IRow, 6)) * (1 - AdoMass.Recordset.Fields("SSUNFL")) * (.TextMatrix(IRow, 5))
.TextMatrix(IRow, 8) = Round(TempSF, 2)
.TextMatrix(IRow, 9) = Round(TempSF, 2)
SumSF = SumSF + (.TextMatrix(IRow, 9))
ORidID(IRow) = ADOdb.Recordset.Fields("ID")
ORidTypename(IRow) = ADOdb.Recordset.Fields("TypeName")
ORidWSCLL(IRow) = ADOdb.Recordset.Fields("SSUNratio")
AdoMass.Recordset.MoveNext
VSgrid.MergeRow(IRow) = True
IRow = IRow + 1
Loop
End With
End If
End If
SumSF = Round(SumSF, 2): ISum = Int(SumSF): SSum = Right(str(Round(SumSF - ISum, 2)), 2)
For Icol = 1 To vsgrid1.Cols - 1
vsgrid1.TextMatrix(0, Icol) = "小写¥" + Trim(str(Format(SumSF, "##,###.00")))
vsgrid1.TextMatrix(1, Icol) = "大写:" + FanYi(str(ISum), SSum)
Next
End If
End Sub --------------------编程问答-------------------- 一个函数这么长,懒得看,帮你顶吧。。。 --------------------编程问答-------------------- 啥问题也不说,真有你的。 --------------------编程问答-------------------- 呵呵呵 --------------------编程问答-------------------- 把你的代码贴在我这里也无法复原出程序,怎么帮你看。而且你的程序什么问题也没说。这么多代码手工分析完全浪费时间。
所以这是一个糟糕的问题。
建议你学会调试,搞清楚问题是什么。实在不行,把最关键的代码贴出来,以及出现的问题描述清楚。 --------------------编程问答-------------------- 代码这么长,还没注释,真心不想看 --------------------编程问答-------------------- 你设置一个断点,然后分步debug。看看哪里出错和错误提示是什么
补充:VB , 数据库(包含打印,安装,报表)