×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

split command

split command

split command

(OP)
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   

RE: split command

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'

RE: split command

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'

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources