tags:

views:

47

answers:

2

Hi,

I have a question for you. I have a dne text file.( file will be in the test server) I need to read that file and store it in a database. In this I have to read line if that line starts with “6”. Other wise leave it. For example in that dne file if the line starts with 6 then read that line and if second line starts with 7 then don’t read it. leave that line. And if third with 6 again read that line.

If the line starts with 6, then I don’t want to read entire line.

I want to read from position 04-11 as rtn number (length = 8)

I want to read from position 13-29 as act number (length= 17)

I want to read from position 30-39 as amt (length= 10)

I want to read from position 55-76 as name (length= 22)

After that assign that to record set and store it in database. This should do until end of file.

Can anyone provide me the code how to do that in vb6?

+1  A: 

This sounds like a homework question, and I think a lot of us are hesitant to answer this question because this is basic stuff. This site is for asking for and giving help, and not getting others to do the work for you. From what you've posted it looks like you want someone to just do th code and give it to you. You won't get that here.

However, most of us do like to help, as I would.

In that spirit, I'll give you some links to point you in the right direction so that you can get the necessary concepts explained, and you can go from there.


http://www.google.com/search?q=vb6+read+a+fixed+width+file&rls=com.microsoft:en-us&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1


http://www.google.com/search?hl=en&safe=active&rls=com.microsoft%3Aen-us&q=vb6+if+statements&aq=f&oq=&aqi=

David Stratton
A: 

Mid$ is your friend. Just read each line and use Mid$ to read one or more characters from the desired position For example

TempS = "Hello World"
Print Mid$(Temps, 2,3)

Result will be 'ell'

The rest should be straight forward.

RS Conley