Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 135,919 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,574 people online right now. Registration is fast and FREE... Join Now!




reading a text file

 
Reply to this topicStart new topic

reading a text file

bhagyanayak
11 May, 2008 - 01:20 AM
Post #1

New D.I.C Head
*

Joined: 11 May, 2008
Posts: 3

from the given file format given below
how to extract the strings present in double quotes and display it in combobox....for eg.
"SNAP_UP_noe"
"1000"
"IS_noe"
.Noe
223518 223590 223596 223636 223640 223645 223717 223723 223763 223767 $
223772 223844 223850
GROUP NOM "SNAP_UP_noe" NOEUDS
I 223869 223870 223871 223872 223874 223899 223900 223901 223902 223904 $
223929 223930 223931 223932 223934 223959 223960 223961 223962 223964 $
223989 223990 223991 223992 223994 224019 224020 224021 224022 224024 $
224049 224050 224051 224052 224054 224079 224080 224081 224082 224084 $
224109 224110 224111 224112 224114 224139 224140 224141 224142 224144 $
225241 225242 225243 225245 225287 225288 225289 225291 225321 225322 $
225323 225324 225326 225368 225369 225370 225372 225402 225403 225404
225405 225407 225449 225450 225451 225453 225483 225484 225485 225486 $
225488 225530 225531 225532 225534 225564 225565 225566 225567 225569 $
225611 225612 225613 225615 225645 225646 225647 225648 225650 225692 $
225693 225694 225696
.SEL GROUP "1000 " NOEUDS
I 217461 217462 217463 217465 217467 217469 217471 217473 217474 217475 $

GROUP NOM "IS_noe" NOEUDS
I 400000 400001 400002 400003 400004 400005 400006 400007 400008 400009 $
400010 400011 400012 400013 400014 400015 400016 400017 400018 400019 $

GROUP NOM "IS_CORNER_noe" NOEUDS
I 400000 400001 400002 400003 400004 400005 400006 400007 400008 400009 $ NTRI 1
400010 400011 400012 400013 400014 400015 400016 400017 400018 400019 $ NTRI 1
400020 400021 400022 400023 400024 400025 400026 400027 400028 400029 $ NTRI 1

400600 400601 400602 400603 400604 400605 400606 400607 400608 4006
RETURN
User is offlineProfile CardPM
+Quote Post

Zhalix
RE: Reading A Text File
11 May, 2008 - 02:20 AM
Post #2

D.I.C Head
**

Joined: 7 May, 2008
Posts: 218



Thanked: 9 times
My Contributions
Please put forth an effort to do it on your own and show us the code you have that's not working. I'll help you, but first I gotta see your attempt.
User is offlineProfile CardPM
+Quote Post

bhagyanayak
RE: Reading A Text File
11 May, 2008 - 02:50 AM
Post #3

New D.I.C Head
*

Joined: 11 May, 2008
Posts: 3

QUOTE(Zhalix @ 11 May, 2008 - 03:20 AM) *

Please put forth an effort to do it on your own and show us the code you have that's not working. I'll help you, but first I gotta see your attempt.



this the code i m using for reading the file

Dim lFile As Integer
Dim sLine As String

lFile = FreeFile()

Open "C:\TEMP\READ.txt" For Input As #lFile
Combo1.Clear
Do While Not EOF(lFile)
Line Input #lFile, sLine
Combo1.AddItem sLine
Loop
Close #lFile
User is offlineProfile CardPM
+Quote Post

Zhalix
RE: Reading A Text File
11 May, 2008 - 03:14 AM
Post #4

D.I.C Head
**

Joined: 7 May, 2008
Posts: 218



Thanked: 9 times
My Contributions
Okay, you're wanting to remove some of the data (the stuff you put into quotes) and put the rest of the data into a huge combobox, right?

First I'd load the entire text file into a string. This is the code I normally use to do that:

CODE

Dim iFile As Long
Dim sFilename As String
Dim TheData as String

sFilename = "C:\....."

iFile = FreeFile

Open sFilename For Input As #iFile
    TheData = Input$(LOF(iFile), #iFile)
Close #iFile


Once the text file is in the string you can search through it and extract the data you want removed.

After all the bad data is removed you can just put the rest into the combo boxes. That's what you want right?

Tell me what you want to happen exactly and give me your best attempt.

This post has been edited by Zhalix: 11 May, 2008 - 03:22 AM
User is offlineProfile CardPM
+Quote Post

bhagyanayak
RE: Reading A Text File
11 May, 2008 - 04:44 AM
Post #5

New D.I.C Head
*

Joined: 11 May, 2008
Posts: 3

QUOTE(Zhalix @ 11 May, 2008 - 04:14 AM) *

Okay, you're wanting to remove some of the data (the stuff you put into quotes) and put the rest of the data into a huge combobox, right?

First I'd load the entire text file into a string. This is the code I normally use to do that:

CODE

Dim iFile As Long
Dim sFilename As String
Dim TheData as String

sFilename = "C:\....."

iFile = FreeFile

Open sFilename For Input As #iFile
    TheData = Input$(LOF(iFile), #iFile)
Close #iFile


Once the text file is in the string you can search through it and extract the data you want removed.

After all the bad data is removed you can just put the rest into the combo boxes. That's what you want right?

Tell me what you want to happen exactly and give me your best attempt.




when i use the above code provided by u the whole file (with all lines are read and displayed in combobox)which is not wat i want i want only particular line having quotes to be extracted and displayed in combobox..is there any delimiter to do tat?since i m new to VB i have no idea how to achieve it.........please help
User is offlineProfile CardPM
+Quote Post

Zhalix
RE: Reading A Text File
11 May, 2008 - 10:24 AM
Post #6

D.I.C Head
**

Joined: 7 May, 2008
Posts: 218



Thanked: 9 times
My Contributions
I'll help, but you need to help yourself too. What I mean by that is you need to read what I write, not just take the code I provide you. The code I gave you is for writing the entire text file to a string. Once the text file is within the string, you'll extract the stuff within the quotes from the string variable.

So you actually want the stuff IN the quotes to BE in the combo box, not the other way around? This is a very important question as it effects the entire way the code will be written. Please answer and also, even though I know you really don't know how, please show me your best attempt at doing this anyway.

This post has been edited by Zhalix: 11 May, 2008 - 10:40 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 08:04AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month