Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

split command

Status
Not open for further replies.

rwbaker

Computer
Mar 27, 2004
37
i use the split command to get two items from the lines i read in a part number and a description

i have run into a problem with it not wanting to split as i thought it would

Open "Y:\MTA" + Text1.Text + "PN" For Input As #xfile
'Load integer values MyArray
Dim strArray() As String
Dim tmpstrarray() As String
Dim tmppstrarray() As String
Dim partdescarray() As String
Dim rbarray() As String
While Not EOF(xfile)
' Obtain the data line
Line Input #xfile, name '<=CHANGED
Debug.Print name
name = RTrim(name)
strArray = Split(name, " ")
'tmpline = stripextrachars(strArray(1), Chr$(32))
'partdesc = stripextrachars(strArray(1), Chr$(32))
rbarray = Split(tmpline, " ")
'dwgsize = rbarray(0)

partnumber = strArray(0)
partdesc = strArray(1)
'qty = rbarray(2)
'linetotal = UBound(rbarray)
'For i = 3 To linetotal
'partdesc = Mid(partdesc, InStr(1, partdesc, " ") + 1)
'partdes = partdes + rbarray(i) + " "
'Next


Set itmX = ListView1.ListItems.Add(, , partnumber)
' Then generate its sub-items
itmX.SubItems(1) = qty
itmX.SubItems(2) = partdesc
'itmX.SubItems(3) = strStatus
partdes = ""

Wend
Close #xfile

here is an example of a file i read in
it will split the first line fine

but not the next 2 all i get is the part number no description

any ideas ?

609B0638229B ONE PIECE COLUMN - 6" DIA. SCH
680B0400-041529A 4" DIA INT. RISER PIPE X 43 5
680B0400-046106A 4" DIA INTERNAL RISER PIPE X
680B0400ELXA 4" DIA INT. RISER PIPE X 180"
682B0400BDXA1 FLOOR PIPE STAND
682B0400BDXA2 PIPE MOUNTING PLATE 4"
682B046EXTA INTERNAL PIPE STAND-OFF BRACKE
704B040F0 NOZ,4"DIA X 6"LG 150# FF
704B080F0 NOZZLE 8 X 6" EXT PROG,150#FF
704B101F2 NOZZ EXT 10X6 FF 150# 15'UP
724B10000 ELBOW 10" W/20SQ VORTEX&LEG
 
Replies continue below

Recommended for you

It appears the delimiter specified in the code:
strArray = Split(name, " ") has 7 spaces.

The two offending lines of data appear to have just FOUR spaces between the sub-items - the code is unable to split is coz it is not able to find the 7 character delimiter specified.



Mala Singh
'Dare to Imagine'
 
Also, it is a good practice to avoid using reserved words like name for naming variables - sometimes it may work at other times the code may behave unpredictably or may crash.


Mala Singh
'Dare to Imagine'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor