473,385 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Need your help: read text file

Hello there,

I am creating a vb application which is some like like a questionare.

Application read a text file which contains many questions and display
one question and the input is needed from user to calculate the score.

Here is a problem.

I can read a text file. However, it's read whole file at a time. So,
it only displays the last question.

Is there any way I can read one line from a text file and wait for a
user input and when user puts an answer and click next then read next
line and wait for a user input and so on.

Do you guys have any idea or hint that I can use?
Any input from you will be appreciated.

Thank you,

Jul 30 '07 #1
6 2451
By the way, I am using Visual Basic 2005.

On Jul 30, 9:12 am, portCo <woos...@gmail.comwrote:
Hello there,

I am creating a vb application which is some like like a questionare.

Application read a text file which contains many questions and display
one question and the input is needed from user to calculate the score.

Here is a problem.

I can read a text file. However, it's read whole file at a time. So,
it only displays the last question.

Is there any way I can read one line from a text file and wait for a
user input and when user puts an answer and click next then read next
line and wait for a user input and so on.

Do you guys have any idea or hint that I can use?

Any input from you will be appreciated.

Thank you,

Jul 30 '07 #2

"portCo" <wo*****@gmail.comwrote in message
news:11**********************@i13g2000prf.googlegr oups.com...
Hello there,

I am creating a vb application which is some like like a questionare.

Application read a text file which contains many questions and display
one question and the input is needed from user to calculate the score.

Here is a problem.

I can read a text file. However, it's read whole file at a time. So,
it only displays the last question.

Is there any way I can read one line from a text file and wait for a
user input and when user puts an answer and click next then read next
line and wait for a user input and so on.

Do you guys have any idea or hint that I can use?
Any input from you will be appreciated.

Thank you,
Assuming that the file contains one question per line you would do the
following :

Read you file as you do now into a string. Then split the string on the
vbcrlf which should give you an array of strings.

Then loop thru you array displaying the question, waiting for the answer,
recording the answer and then going to the next question until the questions
are complete.

Hope this helps

Lloyd Sheen

Jul 30 '07 #3
Thank you for your input.

The file contains like

1. Is VB stand for Visual Bag?, F
2. 1. Is VB stand for Visual Basic?, T

I am confused and not sure about "waiting for the answer". How can I
wait for the answer before go into next question?

This is my question.

Thanks again

-portco

On Jul 30, 9:59 am, "Lloyd Sheen" <a...@b.cwrote:
"portCo" <woos...@gmail.comwrote in message

news:11**********************@i13g2000prf.googlegr oups.com...


Hello there,
I am creating a vb application which is some like like a questionare.
Application read a text file which contains many questions and display
one question and the input is needed from user to calculate the score.
Here is a problem.
I can read a text file. However, it's read whole file at a time. So,
it only displays the last question.
Is there any way I can read one line from a text file and wait for a
user input and when user puts an answer and click next then read next
line and wait for a user input and so on.
Do you guys have any idea or hint that I can use?
Any input from you will be appreciated.
Thank you,

Assuming that the file contains one question per line you would do the
following :

Read you file as you do now into a string. Then split the string on the
vbcrlf which should give you an array of strings.

Then loop thru you array displaying the question, waiting for the answer,
recording the answer and then going to the next question until the questions
are complete.

Hope this helps

Lloyd Sheen- Hide quoted text -

- Show quoted text -

Jul 30 '07 #4
As you mean with a Text file a txt file, formely also called asci file or
whatever, than the answer is simple,

"No'' that is not possible.

You would have to use a binary file (formaly named a random file) or a
database.

However with so much memory today in every computer is the question in my
eyes a little bit sily and will the solution given by Lloyd be good (and
fast) enough as that fits you.

Cor

"portCo" <wo*****@gmail.comschreef in bericht
news:11**********************@i13g2000prf.googlegr oups.com...
Hello there,

I am creating a vb application which is some like like a questionare.

Application read a text file which contains many questions and display
one question and the input is needed from user to calculate the score.

Here is a problem.

I can read a text file. However, it's read whole file at a time. So,
it only displays the last question.

Is there any way I can read one line from a text file and wait for a
user input and when user puts an answer and click next then read next
line and wait for a user input and so on.

Do you guys have any idea or hint that I can use?
Any input from you will be appreciated.

Thank you,
Jul 30 '07 #5

"portCo" <wo*****@gmail.comwrote in message
news:11**********************@i13g2000prf.googlegr oups.com...
Thank you for your input.

The file contains like

1. Is VB stand for Visual Bag?, F
2. 1. Is VB stand for Visual Basic?, T

I am confused and not sure about "waiting for the answer". How can I
wait for the answer before go into next question?

This is my question.

Thanks again

-portco

On Jul 30, 9:59 am, "Lloyd Sheen" <a...@b.cwrote:
>"portCo" <woos...@gmail.comwrote in message

news:11**********************@i13g2000prf.googleg roups.com...


Hello there,
I am creating a vb application which is some like like a questionare.
Application read a text file which contains many questions and display
one question and the input is needed from user to calculate the score.
Here is a problem.
I can read a text file. However, it's read whole file at a time. So,
it only displays the last question.
Is there any way I can read one line from a text file and wait for a
user input and when user puts an answer and click next then read next
line and wait for a user input and so on.
Do you guys have any idea or hint that I can use?
Any input from you will be appreciated.
Thank you,

Assuming that the file contains one question per line you would do the
following :

Read you file as you do now into a string. Then split the string on the
vbcrlf which should give you an array of strings.

Then loop thru you array displaying the question, waiting for the answer,
recording the answer and then going to the next question until the
questions
are complete.

Hope this helps

Lloyd Sheen- Hide quoted text -

- Show quoted text -

The loop asking questions would be implied not a "real" loop. What you
would do is once you have finished reading and parsing (splitting) the file
you will display a question and wait for an answer. The answer will be the
event that you then process the answer and see if there are more questions
to be asked. If so then ask the next (and so on). If the questions are
complete then you will .... do whatever it is you do with the results.

Hope this helps.
Lloyd Sheen

Jul 30 '07 #6
Is there any way I can read one line from a text file and wait for a
user input and when user puts an answer and click next then read next
line and wait for a user input and so on.
Dim Question As String
Dim Answer As String
FileOpen(1, Filename, OpenMode.Input)
While Not EOF(1)
Question = LineInput(1)
Answer=InputBox(Question)
End While
FileClose()

Jul 31 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ADE | last post by:
Hi everyone well from my last post I found what I am looking for I have some code now that transfers files I have added a GUI to it and need some help with two things one my loadtemplate()...
2
by: Keith Kowalski | last post by:
I anm opening up a text file reading the lines of the file that refer to a tif image in that file, If the tif image does not exist I need it to send an email stating that the file doesn't exist...
3
by: AVL | last post by:
Hi, I need some info on text and xml files...... How many users can simultaneously read a text or xml file... I've a web appliaction which needs to access a text file and a xml file.. The...
66
by: genestarwing | last post by:
QUESTION: Write a program that opens and read a text file and records how many times each word occurs in the file. Use a binary search tree modified to store both a word and the number of times it...
8
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only...
13
by: James | last post by:
Is this possible? I want to pass an array into a function that contains txtBox.Text properties... I was thinking something like this, but I know it won't work Dim vendorFields(9) As String ...
4
by: naknak4 | last post by:
Introduction This assignment requires you to develop solutions to the given problem using several different approaches (which actually involves using three different STL containers). You will...
6
by: naknak | last post by:
Introduction This assignment requires you to develop solutions to the given problem using several different approaches (which actually involves using three different STL containers). You will...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
0
by: alivip | last post by:
Is python provide search in parent folder contain sub folders and files for example folder name is cars and sub file is Toyota,Honda and BMW and Toyota contain file name camry and file name corola,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.