?
Solved

Check Boxes and Labels Generation

Posted on 2005-03-04
5
Medium Priority
?
300 Views
Last Modified: 2010-04-17
Hi smart people of the world,
Here is my problem:
I have 2 labels one under the other they are set as a column and I have 2 rows of 10 check boxes in front of them so

label    chk chk chk chk chk chk chk chk chk chk chk chk chk
label    chk chk chk chk chk chk chk chk chk chk chk chk chk

the labes are on a frame and the check boxes are on antoher frame
ok I have 2 set of labels with they respective check boxes, each label will be filled with text that will come from a file as caption, so then I can click on the check box I want those check boxes are 10 because I will use all of them with some other data here is my problem.

My question, I think some one already mention something to me about how to do this but I can not remember.
Can I generate more labels and more check boxes if necesary in the same order as these 2 are now? this is because now these are set fro 2 lines but if there is a new line in the text that I'm reading it will not be despalyed. so some how either I create maunal new label and new checkboxes or they could be generated dynamicaly.??

Thank you
0
Comment
Question by:NEW_INDIA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 13460656
Create a new project and add a Label, CheckBox and a CommandButton.  Set the Index property of the Label and the CheckBox to 0 (zero).  Paste the code below, run it, and hit the button several times:

Private Sub Command1_Click()
    Dim idx As Integer
    idx = Label1.Count
   
    Load Label1(idx)
    Label1(idx).Left = Label1(0).Left
    Label1(idx).Top = Label1(idx - 1).Top + Label1(idx - 1).Height + 15
    Label1(idx).Visible = True
   
    Load Check1(idx)
    Check1(idx).Left = Check1(0).Left
    Check1(idx).Top = Check1(idx - 1).Top + Check1(idx - 1).Height + 15
    Check1(idx).Visible = True
End Sub
0
 

Author Comment

by:NEW_INDIA
ID: 13460893
Idle this is perfect but,
My bigest problem is that I would like if posible that as the txt file is open and I'm reading from it the system should be able to generate the labels and check required for the lines,
So I have a text file and I open it to read what's in it then if have 3 lines in the text file there should be 3 labels generated and 3 sets of check boxes , then if I add a new line to the textfile, there should be a new label box generated and a new check box set too.

is this possible????
Thanks
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 13460937
What you can do is simply create 1 label and 1 set of checkboxes.  These will all have an index of 0 (zero).  Start a counter at -1 and increment it each time you read in the lines from your file.  Then you can check this value against the upper bound of your label array.  If it exceeds the upper bound then you simply add more labels/checkboxes.  Something like:

    Dim i As Integer
    Dim ff As Long
    Dim inputLine As String

    i = -1    
    ff = FreeFile
    Open "D:\Theo\Users.txt" For Input As #ff
    While Not EOF(ff)
        Line Input #ff, inputLine
        i = i + 1
        If i > lbl.ubound Then
            Load lbl(i)
            lbl(i).Left = lb(0).Left
            lb(i).Top = lb(i - 1).Top + lb(i - 1).Height + 15
            lb(i).Visible = True

            ' do something similar for your checkboxes...

        End If
        lbl(i).Caption = inputLine
    Wend
    Close ff
0
 

Author Comment

by:NEW_INDIA
ID: 13461447
Sir,
this work perfect for the labes but now I'm on a problem,
now I have 10 lines in the text file so now I have 10 label boxes with names, this is perfect but now I have 1 check box and
I don't know how to change it so it can work for the check boxes too, also I have a command boton that was designed to check all boxes at the time now I have 10 labels 1 check box and if I click on check all it does not work enymore becasue the checkall.cmd have this
Public Function CheckAll()
'====================
Dim i As Single
i = 0
For i = 0 To 17
If chk(i).Value = vbChecked Then
chk(i).Value = vbUnchecked
Else
chk(i).Value = vbChecked
End If
Next
End Function
but this work no more ...

please help
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 13462503
Change

    For i = 0 To 17

to

    For i = 0 To chk.ubound

0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Six Sigma Control Plans

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question