You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

tcaudilllg

Beginner

  • "tcaudilllg" started this thread

Posts: 1

Date of registration: Jan 26th 2010

  • Send private message

1

Wednesday, January 27th 2010, 5:22am

ListBox control not VB compatible

I get a runtime error every time I try to read or set the Text and ListItem properties.

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

2

Wednesday, January 27th 2010, 9:16am

The following sample routines might inspire you:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Public Function description() As String
   Dim s As String = ""
   Dim slst As String 
   Dim i As Integer 
   Dim k As Integer 
   Dim bMulti As Boolean 
   Dim idx() As Integer 
      
   If List1.ListIndex > 0 Then
      '  one or more fields <> "-" selected
      idx = List1.Parent.getSelectedIndices
      bMulti = UBound(idx) > LBound(idx)
      
      If bMulti Then
         s = Trim(Label1.Caption) & " IN (" 
         For i = LBound(idx) To UBound(idx)
            If Right(s, 1) <> "(" Then
               s = s & ", "
               If i Mod 8 = 0 Then
                  s = s & "<BR/>" & "    "
               End If
            End If
                                       
            s = s & "'" & List1.List(idx(i)) & "'"
         Next i   
         s = s & " )"
      Else
         slst = List1.List(idx(Lbound(idx)))
         s = Trim(Label1.Caption) & " = '#MA" & slst & "#MB'"
      End If      
   End If
   
   description = s
End Function

Public Sub reset
   List1.ListIndex = 0
   List1.Parent.clearSelection 
End Sub

Public Sub selectText(text As String)
   Dim i As Integer 
   
   reset
   
   For i = 0 To List1.ListCount - 1
      If List1.List(i) = text Then
         List1.ListIndex = i
         Exit For
      End If
   Next i
End Sub

Public Function text() As String
   If List1.ListIndex < 0 Then
      text = ""
   Else
      text = List1.List(List1.ListIndex)
   End If
End Function


I think you are right. The implementation of ListBox() is not fully VB6 compatible.

Happy experimenting!

A1880

Rate this thread
WoltLab Burning Board