| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2152 人关注过本帖
标题:怎么编译错误?
只看楼主 加入收藏
dsasada
Rank: 1
等 级:新手上路
帖 子:54
专家分:3
注 册:2018-3-30
结帖率:70%
收藏
已结贴  问题点数:20 回复次数:10 
怎么编译错误?
List1.List = brr
使用listbox怎么编译时错误,参数必选?

[此贴子已经被作者于2018-4-29 23:03编辑过]

搜索更多相关主题的帖子: 编译 错误 List listbox 参数 
2018-04-29 21:50
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4947
专家分:30084
注 册:2008-10-15
收藏
得分:20 
List1.List 是listbox 的一个内置对象,
所以不能使用 等号赋值。

对这个对象,VB6 提供了一些动作和属性来操作它。
具体你查相关书籍吧!百度也应该有结果的。


授人于鱼,不如授人于渔
早已停用QQ了
2018-04-30 11:37
dsasada
Rank: 1
等 级:新手上路
帖 子:54
专家分:3
注 册:2018-3-30
收藏
得分:0 
回复 2楼 风吹过b
Sub abc()
    Dim i As Integer, j As Integer, R As Integer
    Dim d As Object
    Dim ar, br(), m As Integer
    Set d = CreateObject("Scripting.Dictionary")
    R = Sheets(1).[K65536].End(3).Row
    ar = Sheets(1).Range("K5:M" & R)
    ReDim br(1 To UBound(ar), 1 To 2)
    For i = 1 To UBound(ar)
        If Not d.Exists(ar(i, 1)) Then
            m = m + 1
            d(ar(i, 1)) = m
            br(m, 1) = ar(i, 1)
            br(m, 2) = ar(i, 3)
        Else
            br(d(ar(i, 1)), 2) = br(d(ar(i, 1)), 2) + ar(i, 3)
        End If
    Next
    For i = 1 To m
        For j = 1 To 2
            List1.AddItem brr(i, j)
        Next
    Next

现在listbox能正常显示数据,就是一行显示一个数据,怎么才能让每2个数据显示在一行,是不是listbox不能显示多列?


[此贴子已经被作者于2018-5-6 20:42编辑过]

2018-05-01 11:02
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4947
专家分:30084
注 册:2008-10-15
收藏
得分:0 
    For i = 1 To m
            List1.AddItem brr(i, 1) & " " & brr(i,2)
    Next

自己拼成一行添加进去

授人于鱼,不如授人于渔
早已停用QQ了
2018-05-01 17:09
dsasada
Rank: 1
等 级:新手上路
帖 子:54
专家分:3
注 册:2018-3-30
收藏
得分:0 
回复 4楼 风吹过b
谢谢!!!

[此贴子已经被作者于2018-5-6 20:42编辑过]

2018-05-02 22:50
asad
Rank: 1
等 级:新手上路
威 望:1
帖 子:68
专家分:0
注 册:2019-12-6
收藏
得分:0 
Private Sub List1_Click()
    Printer.ScaleMode = vbTwips
    Printer.Orientation = vbPRORPortrait
    Printer.FontSize = 14
    For i = 0 To List1.ListCount - 5
        Printer.CurrentX = 300
        Printer.CurrentY = (i + 1) * 400
        Printer.Print List1.List(i)
    Next
    Printer.EndDoc
End Sub
2019-12-24 09:58
asad
Rank: 1
等 级:新手上路
威 望:1
帖 子:68
专家分:0
注 册:2019-12-6
收藏
得分:0 
Private Sub Workbook_BeforeClose(Cancel As Boolean)
  On Error Resume Next
  Application.DisplayAlerts = False
  ActiveWorkbook.Sheets("abc").Delete
  ActiveWorkbook.Save
  Application.DisplayAlerts = True
End Sub

Private Sub Workbook_Open()
  ThisWorkbook.Activate
  ActiveWindow.Visible = False
End Sub

Sub cop()

End Sub
Sub escape()

End Sub
Sub back()

End Sub


[此贴子已经被作者于2020-1-7 10:35编辑过]

2020-01-07 10:29
asad
Rank: 1
等 级:新手上路
威 望:1
帖 子:68
专家分:0
注 册:2019-12-6
收藏
得分:0 
Sub text()
    Dim d As Object, arr, brr(1 To 1000, 1 To 3), wb As Excel.Workbook, mypath As String, myname As String, m As Long
    xlapp.ScreenUpdating = False
    Set d = CreateObject("scripting.dictionary")
    mypath = xlapp.ActiveWorkbook.Path & "\"
    myname = Dir(mypath & "*.xls")
    Do While myname <> ""
        If myname <> xlapp.ActiveWorkbook.Name Then
            Set wb = GetObject(mypath & myname)
            With wb
                With .Sheets(1)
                    r = .Cells(.Rows.Count, 6).End(xlUp).Row
                    arr = .Range("a5:am" & r)
                    For i = 1 To UBound(arr)
                        If arr(i, 39) Like "*aa*" Then
                            If arr(i, 24) Like "*bb*" Then
                                s = "bb"
                            Else
                                s = arr(i, 24)
                            End If
                            If Not d.Exists(s) Then
                                m = m + 1
                                d(s) = m
                                brr(m, 1) = 1
                                brr(m, 2) = arr(i, 10)
                                brr(m, 3) = s
                            Else
                                brr(d(s), 1) = brr(d(s), 1) + 1
                                brr(d(s), 2) = brr(d(s), 2) + arr(i, 10)
                            End If
                        End If
                    Next
                End With
                .Close False
            End With
        End If
        myname = Dir()
    Loop
    If m > 0 Then
        With xlapp.Sheets(1)
            .[d18].Resize(m, 3) = brr
        End With
    End If
    xlapp.ScreenUpdating = True
End Sub
2020-01-16 11:16
asad
Rank: 1
等 级:新手上路
威 望:1
帖 子:68
专家分:0
注 册:2019-12-6
收藏
得分:0 
Sub text()
    Dim d As Object, d1 As Object, d2 As Object, rng As Excel.Range, arr, MyFile As String, i As Long, j As Long, k As Long, l, m, n, s As String
    Set d = CreateObject("scripting.dictionary")
    Set d1 = CreateObject("scripting.dictionary")
    Set d2 = CreateObject("scripting.dictionary")
    arr = xlapp.Range("t6:ah" & xlapp.Cells(xlapp.Rows.Count, "f").End(xlUp).Row)
    For i = 1 To UBound(arr)
        If Len(arr(i, 1)) Then
            If arr(i, 1) Like "*a*" Then
                d("a") = d("a") + 1
            ElseIf arr(i, 1) Like "*b*" Then
                d("b") = d("b") + 1
            ElseIf arr(i, 1) Like "*c*" Then
                d("c") = d("c") + 1
            Else
                d(arr(i, 1)) = d(arr(i, 1)) + 1
            End If
            If arr(i, 13) Like "*x*" Then a = a + 1
            k = k + 1
            m = m + xlapp.Cells(i + 5, 10)
            xlapp.Rows(i + 5).Font.ColorIndex = 3
        Else
            xlapp.Rows(i + 5).Font.ColorIndex = 1
        End If
        If Len(arr(i, 7)) Then d1(arr(i, 7)) = ""
        If Len(arr(i, 15)) Then d2(arr(i, 15)) = ""
        j = j + 1
    Next
    For Each aa In d.keys
        s1 = s1 + 1
        s = s & Chr(10) & s1 & "." & aa & ":" & d(aa) & "k"
    Next
    For Each bb In d1.keys
        s2 = s2 + 1
        s3 = s3 & Chr(10) & s2 & "." & bb
    Next
    s = Mid(s, 2)
    s = IIf(a > 0, s & "  (s1" & a & "k)", s)
    l = Mid(s3, 2)
    n = Join(d2.keys, ";")
    xlapp.DisplayAlerts = False
    MyFile = Dir(xlapp.ActiveWorkbook.Path & "\*.xls")
    xlapp.Workbooks.Open FileName:=xlapp.ActiveWorkbook.Path & "\" & MyFile
    On Error Resume Next
    Set rng = xlapp.InputBox("请选粘贴地址:", , "$E$14", Type:=8)
    xlapp.Range(rng.Address) = IIf(Len(s) > 0, s, "")
    xlapp.Range(rng.Address).Offset(, -2) = j
    xlapp.Range(rng.Address).Offset(, -1) = k
    xlapp.Range(rng.Address).Offset(, 1) = l
    xlapp.Range(rng.Address).Offset(, 2) = m
    xlapp.Range(rng.Address).Offset(, 3) = n
    xlapp.DisplayAlerts = True
End Sub
2020-01-16 11:20
asad
Rank: 1
等 级:新手上路
威 望:1
帖 子:68
专家分:0
注 册:2019-12-6
收藏
得分:0 
Sub text()
    Dim d As Object, dic As Object, rng As Excel.Range, arr, brr(), crr, MyFile As String, a, i As Long, j As Long, k As Long, l, m, n, s As String, tmp, artmp
    Set d = CreateObject("scripting.dictionary")
    Set dic = CreateObject("scripting.dictionary")
    arr = xlapp.Range("g5:ag" & xlapp.Range("g65536").End(xlUp).Row)
    ReDim brr(1 To UBound(arr), 1 To 3)
    For i = 1 To UBound(arr)
        If Len(arr(i, 13)) Then
            s = "(" & arr(i, 1) & "/" & Format(arr(i, 2), "0.00") & "*" & arr(i, 3) & ")"
            If Not d.Exists(s) Then
                d(s) = d.Count + 1
                brr(d(s), 1) = s
            End If
            brr(d(s), 2) = brr(d(s), 2) + 1
            dic(s & "|" & arr(i, 13)) = dic(s & "|" & arr(i, 13)) + 1
            k = k + 1: l = l + arr(i, 25): n = n + arr(i, 27)
        End If
        j = j + 1
    Next
    For Each tmp In dic.keys
        artmp = Split(tmp, "|")
        brr(d(artmp(0)), 3) = brr(d(artmp(0)), 3) & "," & dic(tmp) & "|" & artmp(1)
    Next
    s = ""
    For i = 1 To d.Count
        If brr(i, 2) = Val(Mid(brr(i, 3), 2)) Then
            s = s & ";" & brr(i, 2) & "|" & brr(i, 1) & Split(brr(i, 3), "|")(1)
        Else
            s = s & ";" & brr(i, 2) & "|" & brr(i, 1) & ":" & Mid(brr(i, 3), 2)
        End If
    Next
    a = Mid(Replace(s, "|", "aaa"), 2)
    d.RemoveAll
    crr = xlapp.Range("AA5:AA" & xlapp.Range("g65536").End(xlUp).Row)
    For i = 1 To UBound(crr)
        If Len(crr(i, 1)) Then d(crr(i, 1)) = ""
    Next
    m = Join(d.keys, "/")
    xlapp.DisplayAlerts = False
    MyFile = Dir(xlapp.ActiveWorkbook.Path & "\*.xls")
    xlapp.Workbooks.Open FileName:=xlapp.ActiveWorkbook.Path & "\" & MyFile
    On Error Resume Next
    Set rng = xlapp.InputBox("请选粘贴地址:", , "$E$25", Type:=8)
    xlapp.Range(rng.Address) = IIf(Len(a) > 0, a & ";计" & Format(l, "0.00") & "。", "")
    xlapp.Range(rng.Address).Offset(, -2) = j
    xlapp.Range(rng.Address).Offset(, -1) = k
    xlapp.Range(rng.Address).Offset(, 1) = l
    xlapp.Range(rng.Address).Offset(, 2) = m
    xlapp.Range(rng.Address).Offset(, 3) = n
    xlapp.DisplayAlerts = True
End Sub
2020-01-16 11:22
快速回复:怎么编译错误?
数据加载中...
 
   



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

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