By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,986 Members | 1,487 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.

retrieving data from text file thru visual basic

P: 11
hi

in the text file iam having the data as mention below.i want 2 retrieve thru vb.

2 34 56 98 245

i want 2 retrive the data individually which is separate by space.

now i can able 2 retrive the first

left(str, (Instr(str,"")) ------ 2

and the last by

Instrrev(str, "") ----------- 245

i cant able 2 retrieve the middle numbers such as 34, 56 , 98.

can anyone give me idea to solve this problem

regards

vivek
Nov 1 '06 #1
Share this Question
Share on Google+
1 Reply


P: 1
You can try with this code:

-----------------------------------------------------------------------------
V = "2 34 56 98 245"
P = 1
SpPos = 1

While SpPos > 0

SpPos = InStr(P, V, Space(1))

If SpPos > 0 Then
RetVal = Mid(V, P, SpPos - P)
Else
RetVal = Mid(V, InStrRev(V, Space(1)) + 1, Len(V) - InStrRev(V, Space(1)) + 1)
End If

P = SpPos + 1

Print RetVal
Wend
-----------------------------------------------------------------------------

This is not the best way to do it ... anyway ... it works.

Bye

Inter7
Nov 1 '06 #2

Post your reply

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