Results 1 to 31 of 31

Thread: How to load a textfile into the first column of a listview?

Threaded View

  1. #23
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    868

    Re: How to load a textfile into the first column of a listview?

    Justin

    If I understand properly, it seems that you might be hitting this branch

    Code:
                        ' is New question
                        If q = Empty Then
                            If MapForm.StudentAnsLBL.Caption = Label1.Caption Then
                                li.SubItems(rr) = aaQList(rr)           ' Qlist
                            End If
                        ' has been Asked
                        Else
                            b = b
                        End If
    You can put a break-point to confirm.

    If that is so, then you've hit the spot that I did not know what you wanted to do
    In your post #18, you had the equivalent line commented out

    Code:
       Dim lIndex As Long
       If QList.ListCount Then
          lIndex = Int(Rnd * QList.ListCount)
          QuestionLBL.Caption = QList.List(lIndex)
              ' QList.RemoveItem lIndex
        End If
    .. so I left that branch unfinished as I assumed that you had a plan in mind.

    If you still have an issue with that, describe what you want to do, and I'll take a look.

    Actually, now that I look at it further, maybe just moving the Exit For statement will do the trick
    Code:
            With Lvwbook
                ' Post Answer
                For ii = 1 To .ListItems.Count
                    b = .ListItems.Item(ii)
                    If b = MapForm.StudentPickLBL.Caption Then      ' StudentPickLBL
                        Set li = Lvwbook.ListItems.Item(ii)
                        ' generate random question
                        rr = Int(Rnd * 14)                          ' preset to 13
                        rr = IIf(rr = 0, 1, rr)                     ' trap for 0
                        q = li.SubItems(rr)
                        Label1.Caption = aaQList(rr)                ' put in cyan label
                        ' is New question
                        If q = Empty Then
                            If MapForm.StudentAnsLBL.Caption = Label1.Caption Then
                                li.SubItems(rr) = aaQList(rr)       ' Qlist
                                Exit For
                            End If
                        ' has been Asked
                        Else
                            b = b
                        End If
                    End If
                Next ii
            End With
    The loop will still be exited if it is a new question.
    But, if the line b = b is encountered, the Loop will continue, generating another random question.

    Let me know if that does the trick.

    EDIT-1.

    Oops, something just occurred to me.
    There is the distinct possibility that you will encounter an endless-loop !!
    Let me tinker with this a bit .. I have a potential solution in mind.


    Spoo
    Last edited by Spooman; Sep 24th, 2017 at 04:28 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width