Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

dxf search help

Status
Not open for further replies.

bustermove

Structural
Mar 17, 2003
1
'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 > &quot;&quot; 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 <> &quot;EOF&quot;
terminate:
Close #1
End Sub
 
Replies continue below

Recommended for you

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 &quot;0&quot;, &quot;0&quot;
groupcodes.Add &quot;5&quot;, &quot;5&quot;
groupcodes.Add &quot;6&quot;, &quot;6&quot;
groupcodes.Add &quot;8&quot;, &quot;8&quot;
groupcodes.Add &quot;10&quot;, &quot;10&quot;
groupcodes.Add &quot;20&quot;, &quot;20&quot;
groupcodes.Add &quot;30&quot;, &quot;30&quot;
groupcodes.Add &quot;100&quot;, &quot;100&quot;
dxffile = &quot;c:\drawing3.dxf&quot;
Open dxffile For Input As #1
dxfsection = &quot;entities&quot;
dxfentity = InputBox(&quot;&quot;, &quot;specify entity name&quot;, &quot;line&quot;)
dxfentity = UCase$(dxfentity)
Do
Line Input #1, groupcode
groupcode = Trim$(groupcode)
Line Input #1, description

If groupcode = &quot;2&quot; And description = dxfsection Then
section = True
If groupcode = &quot;0&quot; And description = &quot;ENDSEC&quot; Then
section = False
If section = True Then
If groupcode = &quot;0&quot; And description = dxfentity Then
entity = True
ElseIf groupcode = &quot;0&quot; And description <> dxfentity Then
entity = False
If dxfsection > &quot;&quot; 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 <> &quot;EOF&quot;
Terminate:
Close #1
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor