BOOKTABLE is a Userform that has 66 labels with label names Genesis to Revelation.
A user clicks on any Label. The label name is immediately inserted into Textbox1.
The click event then displays BOOKCHAPTER userform in front. BOOKCHAPTER has 80 labels with their text names as numbers (one = 1, etc)
The user clicks any number. The code displays 1 space followed by the label number. Textbox1 now displays
The BOOKCHAPTER click event displays the CHAPTERVERSE userform in front of the other two. This form has 100 labels with label text names and numbers as the entry
(seven = 7)
Textbox1 now finally displays
I don't really understand how this ocde works, but it does work very well. Problem is, I need to do this for the two other userforms
BOOKCHAPTER with number names as text = one - "1"(entered number), two = "2", etc.
as with
CHAPTERVERSE, the end result being in te xtbox1 any combinaton of these
A user clicks on any Label. The label name is immediately inserted into Textbox1.
Code:
Textbox1.value = Daniel
The user clicks any number. The code displays 1 space followed by the label number. Textbox1 now displays
Code:
Textbox1.value = Daniel 7:
(seven = 7)
Textbox1 now finally displays
Code:
Textbox1.value = Textbox1.value + BOOKCHAPTER.value = "Daniel 7:20" (of course w/out quotes)
That is it. My limited experience has me hardcoding every single label item on every userform to give the correct result 300 times and about 8 hours of work
There must be an easier way to construct code for a generic form that would easily do this.
A fellow member very graciously helped me with this code:
[code]
'Add a class module called LabelClicker:
Public tb As msforms.TextBox - tb is a special forms variable?
Public WithEvents lb As msforms.Label lb the same?
Private Sub lb_Click()
tb.Text = lb.Name - what does this do ?
End Sub
then in your userform you need:
VBA Code:
Dim colHandler As Collection - if colHandler is a variable , what is a Collection?
Private Sub UserForm_Initialize()
Dim ctl As msforms.Control - assigning a variable to a control type?
Dim oHandler As LabelClicker
Set colHandler = New Collection
For Each ctl In Me.Controls
If TypeName(ctl) = "Label" Then
Set oHandler = New LabelClicker
Set oHandler.lb = ctl
Set oHandler.tb = Me.TextBox1 '
The bottom line is, if I want to use this code for any new textboxes, can I just copy it?
The question is, where do the changes in this code need to be made to work for any userform ?
BOOKCHAPTER with number names as text = one - "1"(entered number), two = "2", etc.
as with
CHAPTERVERSE, the end result being in te xtbox1 any combinaton of these
Code:
Textbox1.value = "Daniel 7:20" or "Genesis 12:3", etc.
Can anyone please help me with this. I want to learn what each code line does, not just copy code.
(Feel a bit guilty for having to rely on the Message Board experts for what seemingly is very simple - if you know the correct code)
Pictured below is everything I've explained above>
Thanks, cr