Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21243

Click event through Module

$
0
0
I was trying to get click event through module for list box

Form Load
Code:

Private Sub Form_Load()
With List1
.AddItem "a"
.AddItem "a"
.AddItem "a"
.AddItem "a"
.AddItem "a"
End WIth
End Sub

List1

Code:

Private Sub List1_Click()
 List2.Clear
      Select Case List1.Text
        Case "a":  List2_Item_1
        Case "b":  List2_Item_2
        Case "c":  List2_Item_3
        Case "a":  List2_Item_4
        Case "d":  List2_Item_5

End Select
End Sub

Module

Code:

Public Sub List1_Item_1()
    With Form1.List2
    .AddItem "apple"
    .AddItem "banana"
  End with
End Sub
Public Sub List1_Item_2()
    With Form1.List2
    .AddItem "bat"
    .AddItem "ball"
  End with
End Sub
Public Sub List1_Item_3()
    With Form1.List2
    .AddItem "rat"
    .AddItem "cat"
  End with
End Sub
Public Sub List1_Item_4()
    With Form1.List2
    .AddItem "orange"
    .AddItem "penut"
  End with
End Sub
Public Sub List1_Item_5()
    With Form1.List2
    .AddItem "simple"
    .AddItem "hard"
  End with
End Sub


in list1 there are two same Subroutines in select case block [a] .. when I try to execute click event for 2nd Subroutines having the same case [a] .. it shows the value of first one whereas as it has assigned different value

First a is apple , banana
2nd a is rat, cat

but 2nd a when clicked it does not show rat, cat but apple banana ... How I can execute them separately

Viewing all articles
Browse latest Browse all 21243

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>