By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,986 Members | 1,522 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,986 IT Pros & Developers. It's quick & easy.

reading and opening textfile.. Need help...

P: 10
Hi,

I am trying to access a text file in vb6, well I have accessed it but it gives me per line result. I need the exact character given a specific position. Is there any way to access the file and return values per character???

Thanks in advance =)
Dec 19 '07 #1
Share this Question
Share on Google+
6 Replies


Expert 5K+
P: 8,434
I am trying to access a text file in vb6, well I have accessed it but it gives me per line result. I need the exact character given a specific position. Is there any way to access the file and return values per character?
Yes. Open the file For Binary rather than For Input. Then use the Get statement to read from it. You can specify the location to read, or it will just continue from where it's up to. The size of the variable you read the data into will determine how much it reads. So if you define a variable as String * 1 for example, you can read one byte at a time.
Dec 19 '07 #2

lotus18
100+
P: 866
Hi there

Click this link click me. Hope you can get your answer here.

Rey Sean
Dec 19 '07 #3

P: 10
Yes. Open the file For Binary rather than For Input. Then use the Get statement to read from it. You can specify the location to read, or it will just continue from where it's up to. The size of the variable you read the data into will determine how much it reads. So if you define a variable as String * 1 for example, you can read one byte at a time.
Thanks for the quick response... But I do have additional questions.. Can I use Binary File Access given a specific line. To explain it further here is the scenario:

I have this text file...
H5J0001T20071127 -2 0
1BAGICN2101500015063190101500150
SBAGICN01
2 Y 01500000000000000000000000000000
4 Y0000000000000000000000000000000011
H5J0001T20071129000C0
1BAGICN4101500015063190101500150
SBAGICN01

I need to read the line with H as the first character. With that specific line I need to extract the data by reading the character with a given position..
I really appreciate your help... again thank you...
Dec 19 '07 #4

Expert 5K+
P: 8,434
Oops. Forget binary mode.

Just read line by line, and use the Left() and/or Mid() functions to pull the desired characters out of the text.
Dec 19 '07 #5

P: 10
Oops. Forget binary mode.

Just read line by line, and use the Left() and/or Mid() functions to pull the desired characters out of the text.
Ahhh.. yeah. How come I didn't think of that solution? Hehehehe. Thanks for the help...=)
Dec 19 '07 #6

Expert 5K+
P: 8,434
Ahhh.. yeah. How come I didn't think of that solution? Hehehehe. Thanks for the help...=)
Give it a couple of years - experience makes the difference.

We're always glad to help around here. :)
Dec 19 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.