Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General / July 2007



Tip: Looking for answers? Try searching our database.

Reading Text Files

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob Jones - 30 Jul 2007 13:49 GMT
I am working on a quiz type program that will read the questions from
a TXT file. I was wondering what the best way to seperate every
question and still have the ability to read it from the txt file and
write them to a text box on the program. All help would be
appreciated. Also I am using VB 6 and not 2005
Mike D Sutton - 30 Jul 2007 13:59 GMT
>I am working on a quiz type program that will read the questions from
> a TXT file. I was wondering what the best way to seperate every
> question and still have the ability to read it from the txt file and
> write them to a text box on the program. All help would be
> appreciated. Also I am using VB 6 and not 2005

Use a CSV file (comma separated variables) and Input to read the data.
I.e:

*** Data.csv
Alpha,Bravo,Charlie
***

***
Dim FNum As Integer
Dim A As String, B As String, C As String

FNum = FreeFile()
Open "Data.csv" For Input Access Read As #FNum
   Input #FNum, A, B, C
   Debug.Print "A: """ & Alpha & """, B: """ & B & """, C: """ & C & """"
Close #FNum
***

Hope this helps,

   Mike

- Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: Http://EDais.mvps.org/
dpb - 30 Jul 2007 14:37 GMT
> I am working on a quiz type program that will read the questions from
> a TXT file. I was wondering what the best way to seperate every
> question and still have the ability to read it from the txt file and
> write them to a text box on the program. All help would be
> appreciated. Also I am using VB 6 and not 2005

Since the questions presumably are sentences, I'd suggest putting them
in a file with Write # and use Input # to read them in.  This takes care
of the embedded blanks, etc., automagically that Print # and Input #
don't handle w/o special consideration.

--
Ken Halter - 30 Jul 2007 15:30 GMT
>I am working on a quiz type program that will read the questions from
> a TXT file. I was wondering what the best way to seperate every
> question and still have the ability to read it from the txt file and
> write them to a text box on the program. All help would be
> appreciated. Also I am using VB 6 and not 2005

Here's an extremely easy way....

Easy INI File Access
http://www.vbaccelerator.com/home/vb/code/Libraries/Registry_and_Ini_Files/Easy_
Ini_File_Access/article.asp


Signature

Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
In Loving Memory - http://www.vbsight.com/Remembrance.htm

Jeff Johnson - 31 Jul 2007 21:23 GMT
>I am working on a quiz type program that will read the questions from
> a TXT file. I was wondering what the best way to seperate every
> question and still have the ability to read it from the txt file and
> write them to a text box on the program. All help would be
> appreciated. Also I am using VB 6 and not 2005

While there's a much larger learning curve involved, this sounds like an
excellent opportunity to delve into the world of XML.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.