×
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

dxf search help

dxf search help

dxf search help

(OP)
'Please help ! I have copied this function right out of a book and I keep getting a compile error message regarding "loop without Do" even though a "do" is there in the code.Does anyone know why this is?
what am I forgetting?
'
'
'

Sub dxfsearch()
Dim dxffile, dxfsection, dxfentity, groupcode, _
description, dxfselection As String
Dim section, entity As Boolean
Dim GC As Variant
Dim groupcodes As Collection
Set groupcodes = New Collection
groupcodes.Add "0", "0"
groupcodes.Add "5", "5"
groupcodes.Add "6", "6"
groupcodes.Add "8", "8"
groupcodes.Add "10", "10"
groupcodes.Add "20", "20"
groupcodes.Add "30", "30"
groupcodes.Add "100", "100"
dxffile = "c:\winnt\temp\a4430004.dxf"
Open dxffile For Input As #1
dxfsection = "entities"
dxfentity = InputBox("", "specify entity name", "line")
dxfentity = UCase$(dxfentity)
Do
Line Input #1, groupcode
        groupcode = Trim$(groupcode)
    Line Input #1, description

    If groupcode = "2" And description = dxfsection _
        Then section = True
    If groupcode = "0" And description = "ENDSEC" _
        Then section = False
    
    If section = True Then
        If groupcode = "0" And description = dxfentity _
           Then
             entity = True
    ElseIf groupcode = "0" And _
        description <> dxfentity Then
        entity = False
        If dxfsection > "" Then
        If MsgBox(dxfselection + vbCr, vbOKCancel) _
        = vbCancel Then GoTo treminate
    End If
    If entity = True Then
       For Each GC In groupcodes
           If groupcode = groupcodes.Item(GC) Then
            If groupcode = 0 Then dxfselection = _
                dxfselection + vbCr
    dxfselection = dxfselection + _
            groupcode + vbTab + _
            description + vbCr
            End If
        Next
    End If
End If
Loop While description <> "EOF"
terminate:
Close #1
End Sub

RE: dxf search help

Hi,
I looked at it and it was hard for me to follow so I reformatted it a little. It works for me now, give it a try.

Sub dxfsearch()
Dim dxffile, dxfsection, dxfentity, groupcode, _
description, dxfselection As String
Dim section, entity As Boolean
Dim GC As Variant
Dim groupcodes As Collection
Set groupcodes = New Collection
groupcodes.Add "0", "0"
groupcodes.Add "5", "5"
groupcodes.Add "6", "6"
groupcodes.Add "8", "8"
groupcodes.Add "10", "10"
groupcodes.Add "20", "20"
groupcodes.Add "30", "30"
groupcodes.Add "100", "100"
dxffile = "c:\drawing3.dxf"
Open dxffile For Input As #1
dxfsection = "entities"
dxfentity = InputBox("", "specify entity name", "line")
dxfentity = UCase$(dxfentity)
Do
    Line Input #1, groupcode
    groupcode = Trim$(groupcode)
    Line Input #1, description

    If groupcode = "2" And description = dxfsection Then
        section = True
        If groupcode = "0" And description = "ENDSEC" Then
            section = False
            If section = True Then
                If groupcode = "0" And description = dxfentity Then
                    entity = True
                ElseIf groupcode = "0" And description <> dxfentity Then
                    entity = False
                    If dxfsection > "" Then
                        If MsgBox(dxfselection + vbCr, vbOKCancel) = vbCancel Then
                            GoTo Terminate
                        End If
                        If entity = True Then
                            For Each GC In groupcodes
                                If groupcode = groupcodes.Item(GC) Then
                                    If groupcode = 0 Then
                                        dxfselection = dxfselection + vbCr
                                        dxfselection = dxfselection + _
                                            groupcode + vbTab + description + vbCr
                                    End If
                                End If
                            Next
                        End If
                    End If
                End If
            End If
        End If
    End If
Loop While description <> "EOF"
Terminate:
Close #1
End Sub

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