请帮我翻译VB的程序代码,那个去方出的错,没有数据示显出来?
每句或每段代码的作用是什么,那个去方的错数据出不来?请帮看下,翻译下,谢谢!!!(一)
Dim Zname As String
Dim Cname As String
Dim Dname As String
Dim ZNname As String
Dim i As Integer
Dim q As Integer
Private Sub Tree_change() '声明一个树状显示数据的过程
Dim Objrs As New Recordset
On Error Resume Next
Dim key, text As String
Objrs.Open "select * from 用户基础信息 order by 类别编号", Sqlcn, adOpenKeyset, adLockOptimistic
If Objrs.RecordCount > 0 Then
With Objrs
.MoveFirst
Do While .EOF = False
If Len(.Fields("类别编号")) = 2 Then
key = Trim(.Fields("类别名称"))
'text = "(" & Trim(.Fields("类别编号")) & ")" & Trim(.Fields("类别名称"))
text = Trim(.Fields("类别名称"))
Set Node1 = TreeView1.Nodes.Add(, , key, text, Val(.Fields("级别")))
End If
If Len(.Fields("类别编号")) = 5 Then
key = Trim(.Fields("类别名称"))
text = Trim(.Fields("类别名称"))
Set Node2 = TreeView1.Nodes.Add(Node1.Index, tvwChild, key, text, Val(.Fields("级别")))
End If
If Len(.Fields("类别编号")) = 9 Then
key = Trim(.Fields("类别名称"))
text = Trim(.Fields("类别名称"))
Set Node3 = TreeView1.Nodes.Add(Node2.Index, tvwChild, key, text, Val(.Fields("级别")))
End If
.MoveNext
Loop
End With
End If
End Sub
Private Sub Form_Load()
Tree_change
flex1.ColWidth(0) = flex1.ColWidth(0) / 2
flex1.Rows = 2
flex1.Cols = 8
b1$ = "^编号|<路名 |<街道 |<门牌号 |<姓名 |<品种 |>数量 |>金额 "
flex1.FormatString = b1$
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.key
Case Is = "pr"
If flex1.TextMatrix(1, 1) = "" Then
MsgBox "没有可导出的资料", , "提示"
Exit Sub
End If
On Error GoTo Ert
Me.MousePointer = 11
Set Excelapp = New Excel.Application
On Error Resume Next
DoEvents
Excelapp.SheetsInNewWorkbook = 1
Excelapp.Workbooks.Add
Excelapp.ActiveSheet.Cells(1, 3) = S
Excelapp.Range("C1").Select
Excelapp.Selection.Font.FontStyle = "Bold"
Excelapp.Selection.Font.Size = 16
With flex1
k = .Rows
For i = 0 To k - 1
For j = 1 To .Cols - 1
DoEvents
Excelapp.ActiveSheet.Cells(1 + i, j) = "'" & .TextMatrix(i, j)
Next j
Next i
End With
Me.MousePointer = 0
Excelapp.Visible = True
Exit Sub
Ert:
MsgBox "请确认您的电脑已安装Excel!", vbExclamation, "提示"
Set xlApp = Nothing
Set xlBook = Nothing
Set xlSheet = Nothing
Case Is = "no"
VSdel flex1: VSdel flex2
Case Is = "exit"
Unload Me
End Select
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
Dim Objrs As New Recordset
Dim u As String
Dim Y As String
Dim g As Integer
On Error Resume Next
VSdel flex2
VSdel flex1
If Objrs.State <> adStateClosed Then Objrs.Close
Objrs.Open "select * from 用户基础信息 where 类别名称='" & TreeView1.SelectedItem.key & "'", Sqlcn, adOpenKeyset, adLockOptimistic
If Objrs.RecordCount > 0 Then
u = Val(Objrs.Fields("级别").Value)
Y = Objrs.Fields("类别编号").Value
Else
Exit Sub
End If
If u = "1" Then
q = 2
ElseIf u = "2" Then
q = 5
ElseIf u = "3" Then
q = 9
End If
If Objrs.State <> adStateClosed Then Objrs.Close
Objrs.Open "select * from 用户基础信息 where 级别='" & "4级" & "'", Sqlcn, adOpenKeyset, adLockOptimistic
If Objrs.RecordCount > 0 Then
For i = 1 To Objrs.RecordCount
If Y = Mid(Objrs.Fields("类别编号").Value, 1, q) And Len(Objrs.Fields("类别编号").Value) = 14 Then
If flex2.TextMatrix(1, 1) = "" Then
flex2.TextMatrix(1, 1) = Objrs.Fields("类别名称").Value
Else
flex2.AddItem ""
flex2.TextMatrix(flex2.Rows - 1, 1) = Objrs.Fields("类别名称").Value
End If
End If
Objrs.MoveNext
Next
Else
Exit Sub
End If
For i = 1 To flex2.Rows - 1
If Objrs.State <> adStateClosed Then Objrs.Close
Objrs.Open "select 预付1表.品种,预付1表.数量,预付1表.金额 from 预付1表,预付2表,预付3表,预付4表 where 预付1表.姓名='" + flex2.TextMatrix(i, 1) + "' and 预付1表.品种=预付2表.品种 and 预付1表.品种=预付3表.品种 and 预付1表.品种=预付1表.品种 ", Sqlcn, adOpenKeyset, adLockOptimistic
If Objrs.RecordCount > 0 Then
For q = 1 To Objrs.RecordCount
ZNxx
If flex1.TextMatrix(1, 1) = "" Then
flex1.TextMatrix(1, 1) = Zname
flex1.TextMatrix(1, 2) = Cname
flex1.TextMatrix(1, 3) = Dname
flex1.TextMatrix(1, 4) = flex2.TextMatrix(i, 1)
flex1.TextMatrix(1, 5) = Objrs.Fields("品种").Value
flex1.TextMatrix(1, 6) = Objrs.Fields("数量").Value
flex1.TextMatrix(1, 7) = Objrs.Fields("金额").Value
Else
flex1.AddItem ""
flex1.TextMatrix(flex1.Rows - 1, 1) = Zname
flex1.TextMatrix(flex1.Rows - 1, 2) = Cname
flex1.TextMatrix(flex1.Rows - 1, 3) = Dname
flex1.TextMatrix(flex1.Rows - 1, 4) = flex2.TextMatrix(i, 1)
flex1.TextMatrix(flex1.Rows - 1, 5) = Objrs.Fields("品种").Value
flex1.TextMatrix(flex1.Rows - 1, 6) = Objrs.Fields("数量").Value
flex1.TextMatrix(flex1.Rows - 1, 7) = Objrs.Fields("金额").Value
End If
Next
End If
Next i
flex1.Rows = flex1.Rows + 1
flex1.TextMatrix(flex1.Rows - 1, 5) = "合计:"
For i = 1 To flex1.Rows - 2
If flex1.TextMatrix(flex1.Rows - 1, 6) <> "" Then
flex1.TextMatrix(flex1.Rows - 1, 6) = CDbl(flex1.TextMatrix(flex1.Rows - 1, 6)) + CDbl(flex1.TextMatrix(i, 6))
Else
flex1.TextMatrix(flex1.Rows - 1, 6) = CDbl(flex1.TextMatrix(i, 6))
End If
If flex1.TextMatrix(flex1.Rows - 1, 7) <> "" Then
flex1.TextMatrix(flex1.Rows - 1, 7) = CDbl(flex1.TextMatrix(flex1.Rows - 1, 7)) + CDbl(flex1.TextMatrix(i, 7))
Else
flex1.TextMatrix(flex1.Rows - 1, 7) = CDbl(flex1.TextMatrix(i, 7))
End If
Next
'Glk flex1
VSpx flex1
End Sub
Private Sub ZNxx()
Dim Objrs As New Recordset
Dim u As String
If Objrs.State <> adStateClosed Then Objrs.Close
Objrs.Open "select * from 用户基础信息 where 姓名='" & flex2.TextMatrix(i, 1) & "'", Sqlcn, adOpenKeyset, adLockOptimistic
If Objrs.RecordCount > 0 Then
u = Objrs.Fields("类别编号").Value
Else
Exit Sub
End If
If Objrs.State <> adStateClosed Then Objrs.Close
Objrs.Open "select * from 用户基础信息 where 类别编号='" & Mid(u, 1, 9) & "'", Sqlcn, adOpenKeyset, adLockOptimistic
If Objrs.RecordCount > 0 Then
Dname = Objrs.Fields("类别名称").Value
Else
Exit Sub
End If
Set Objrs = Nothing
If Objrs.State <> adStateClosed Then Objrs.Close
Objrs.Open "select * from 用户基础信息 where 类别编号='" & Mid(u, 1, 5) & "'", Sqlcn, adOpenKeyset, adLockOptimistic
If Objrs.RecordCount > 0 Then
Cname = Objrs.Fields("类别名称").Value
Else
Exit Sub
End If
If Objrs.State <> adStateClosed Then Objrs.Close
Objrs.Open "select * from 用户基础信息 where 类别编号='" & Mid(u, 1, 2) & "'", Sqlcn, adOpenKeyset, adLockOptimistic
If Objrs.RecordCount > 0 Then
Zname = Objrs.Fields("类别名称").Value
Else
Exit Sub
End If
End Sub
--------------------编程问答-------------------- 晕,这么多让人翻译 --------------------编程问答-------------------- 刚刚学VB,实在看不懂,帮帮忙了,谢谢了 --------------------编程问答-------------------- 单步调试一下,看代码报错的黄色指示停在哪句上 --------------------编程问答-------------------- 没有代码报错提示,列表中就是看不到有记录显示,因为看不懂代码,就更不知该从何下手 --------------------编程问答-------------------- 数据库里是否有要的数据? --------------------编程问答-------------------- 都有了的,不知道是那个地方调用错了或者别的 --------------------编程问答-------------------- Sqlcn的连接串(数据库连接串)在哪里?
--------------------编程问答-------------------- kkk --------------------编程问答--------------------
我看不懂,所以不知道 --------------------编程问答-------------------- 慢慢看吧,没有能替代你的
补充:VB , 基础类