Results 1 to 4 of 4

Entering input and clicking buttons during loop

Threaded View

  1. #1
    Registered User
    Join Date
    03-22-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    11

    Entering input and clicking buttons during loop

    Hi guys,

    I'm new here and am fairly new to VBA. I have a problem and I don’t know how to solve it in VBA. I have spent some time thinking about this and have so far not got any help on the net.

    I am basically creating a questionnaire style program where the user gets asked 50 questions, one by one and they input their answer and press another button (submit button). They initially press a start button to start the questionnaire.

    So far, I have created a range of questions and it fills one row where the questions are entered. In intend to use a for loop to go though all 50 questions.

    Now this is where I’m stuck. I have a submit button and after each question is displayed, I want the user to enter their answer and then click the submit button to then continue to the next question.

    However, I can’t think of how to do this.

    1. Firstly, how can I loop through the questions and yet allow the user to input their answers after each iteration?
    2. Also can I even click the submit button during the loop phase? I.e. when already running.

    Here is the for loop I have:

    Public Sub AskQuestions()
       
        For QuestionNo = 1 To 50
            Worksheets("test").Range("D11:E11").ClearContents
            Worksheets("test").Range("B11").Value = QuestionNo
            Worksheets("test").Range("C11").Value = QuArray(QuestionNo)
            'check submit button as been pressed
            
            Exit For
        Next QuestionNo
    
    End Sub
    Any help on this is much appreciated. I’m guessing I need some of Boolean for when the button is pressed but don’t know how to incorporate it into my code. I also want a clear button so that the user can reset their answer if they mess it up. But I’m hoping this solution will help me with that.

    Thanks,

    FJ
    Last edited by FlyinJack; 03-23-2009 at 01:49 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1