Re: Newbie problem: Long list of user choices
- From: "Rick Rothstein [MVP - Visual Basic]" <rickNOSPAMnews@xxxxxxxxxxxxxxxxx>
- Date: Sun, 20 Nov 2005 05:17:10 -0500
> I would like to write an application where I can prompt the user
to
> complete a form, that has potentially hundreds of questions.
The
> questions are stored in a flat-file with a specific format:
>
> xxx|Text Question 1
> xxx|Text Question 2
> xxx|Text Question 3
>
> where the xxx is a special identifier for the question. The
user is
> presented with a checkbox next to the text question and simply
has to
> check the box or leave it blank.
>
> I could create a series of forms with say, 10 questions on each
form,
> then have the user answer the 10 questions, then click a button
to move
> onto the next page of questions.
>
> BUT
>
> I the list of questions is dynamic in length, so I would prefer
the user
> to be presented with a single form containing a scrollable
control on
> the form, that would contain the checkboxes and questions
retrieved from
> the flat-file.
>
> In MS Access I could have a subform in a mainform, but I want
this
> application to standalone from MS Office. I started writing this
idea as
> a web-page (html) with javascript, but thought there must be a
better
> way in VB6?
>
> My question: What control do I use?
You might try an MSFlexGrid control. Here is a sample (modify it
to suit your taste) showing a first column that can be clicked in
order to toggle a checkmark and a second column to hold the
questions. Simply add an MSFlexGrid control to your project
(select from the dialog box that appears when you press Ctrl+T)
and copy/paste the following code into the form's code window.
Rick
Const NUMBEROFQUESTIONS As Long = 50
Private Sub Form_Load()
Dim X As Long
With MSFlexGrid1
' I am assuming there is no fixed columns
.FixedCols = 0
' Place headers in a single fixed row
.FixedRows = 1
.FormatString = "Chk|Questions"
' Set up a sample grid
.Cols = .FixedCols + 2
.ColWidth(.FixedCols + 1) = 5000
.Rows = .FixedRows + NUMBEROFQUESTIONS
For X = .FixedRows To .Rows - 1
.Row = X
' Set checkbox column to bolsd and center-center alignment
.Col = .FixedCols
.CellFontBold = True
.CellAlignment = flexAlignCenterCenter
' Set question description row to left-center alignment
.Col = .FixedCols + 1
.CellAlignment = flexAlignLeftCenter
' Set a reasonable row height
.RowHeight(X) = 350
' Place the questions text here. Since we are in a loop
' it would make sense to have that text store in an array
' so that it can easily be read out... here, I am just
' making the text up on the fly.
.TextMatrix(.Row, .FixedCols + 1) = "Question #" & _
CStr(X - .FixedRows + 1) & " goes here."
Next
End With
End Sub
Private Sub MSFlexGrid1_Click()
With MSFlexGrid1
' Toggle a checkmark only if the checkmark column was clicked
If .Col = .FixedCols Then
.Text = IIf(.Text = "", "X", "")
End If
End With
End Sub
.
- References:
- Newbie problem: Long list of user choices
- From: SmilingPolitely
- Newbie problem: Long list of user choices
- Prev by Date: Re: Newbie problem: Long list of user choices
- Next by Date: Re: Newbie problem: Long list of user choices
- Previous by thread: Re: Newbie problem: Long list of user choices
- Next by thread: Re: Newbie problem: Long list of user choices
- Index(es):
Loading