CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2000
    Location
    IL, U.S.A.
    Posts
    218

    Input sequential file

    I have a sequential file to input the first two lines are this:
    Data-types Quiz, 8
    1, What data-type would you use for the population of Chicago?, LONG,LONG,lng,1

    The first variable is a string for Data-types Quiz

    The second variable is a Integer that makes a control array with 8
    buttons.

    The second line is a string that is shown on a label. I can input the
    first line into the program and make the buttons with this code:

    Input #intFileNum, strTestName, intNumberOfQuestions

    and I make the buttons and show the question in the label with this code:

    For intLoadQuestions = 1 To intNumberOfQuestions
    Call MakeTheButtons(intLoadQuestions)
    For intLoadFields = 1 To 6
    Input #intFileNum, g_strQuestionsAndAnswers(intLoadFields, intLoadQuestions)
    Next intLoadFields
    g_strQuestionsAndAnswers(intLoadFields, intLoadQuestions) = "<Enter you answer>"
    Next intLoadQuestions

    Close #intFileNum


    How do I input the answeres in the text file? I want to put them into
    an array and and the three answers into a array and and compare them
    to the answere I input into the text box. I can't change the text file.


  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Input sequential file


    for intLoadQuestions = 1 to intNumberOfQuestions
    dim strQnA as string
    dim arrQnA
    Call MakeTheButtons(intLoadQuestions)
    ' for intLoadFields = 1 to 6
    ' input #intFileNum, g_strQuestionsAndAnswers(intLoadFields, intLoadQuestions)
    ' next intLoadFields
    ' g_strQuestionsAndAnswers(intLoadFields, intLoadQuestions) = "<Enter you answer>"
    '
    Line input #intFileNum, strQnA
    arrQnA=Split(strQnA,",")
    '
    'Now arrQnA(0) contains 1,
    ' arrQnA(1) contains your question
    ' and arrQnA(2) onwards hold the answers.
    'You can do whatever you like with these. Display them and compare them using the regular methods.
    next intLoadQuestions






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

Featured