table

M

MarcoPolo

i have a file txt that is Code,Surname, Phone Number,Telefax

I do a loop to look the first 5 char of the string to read if the code is
the one entered

Do while not eof(1)
. line input #1, strBuffer
if mid(strBuffer,1,5) = txtCodeEntered.text then
......

How can i store the Surname tht is starting fixed at row 6 but variable
lenght?
 
D

Dave Lett

Hi,

If you're willing to reconsider how you import your information, then you
might be able to use the Split () function, as in the following example:

Dim sString As String
Dim aArray
Dim iCounter As Integer
sString = "Code,Surname,Phone Number,Telefax"
aArray = Split(Expression:=sString, Delimiter:=",")
For iCounter = 0 To UBound(aArray)
MsgBox aArray(iCounter)
Next iCounter

HTH,
Dave
 
P

Peter Jamieson

Code,Surname, Phone Number,Telefax

suggests that your file is comma-delimited. If so, you could use

Do while not eof(1)
. line input #1, strBuffer
if mid(strBuffer,1,5) = txtCodeEntered.text then
strSurname = Mid(strBuffer,7,InStr(7,strBuffer,",")-7)

if there is no guarantee that there are "," characters aftert the Surname,
you can use

strSurname = Mid(strBuffer & ",",7,InStr(7,strBuffer & ",",",")-7)


Peter Jamieson
 
M

MarcoPolo

SUPER!!!!!!!!!





Dave Lett said:
Hi,

If you're willing to reconsider how you import your information, then you
might be able to use the Split () function, as in the following example:

Dim sString As String
Dim aArray
Dim iCounter As Integer
sString = "Code,Surname,Phone Number,Telefax"
aArray = Split(Expression:=sString, Delimiter:=",")
For iCounter = 0 To UBound(aArray)
MsgBox aArray(iCounter)
Next iCounter

HTH,
Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top