VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Displaying a 0

3 REPLIES 3
Reply
Message 1 of 4
tony.ecord
214 Views, 3 Replies

Displaying a 0

I must be having a programming block, because I cannot for the life of me figure this out, and I know it's a simple solution.

 

I have code that updates a zone table block with attributes.

When the macro is run, if there are no polylines on certain layers or those polylines have areas that round down to 0 square feet, the macro updates the attributes with nothing.

My boss would like to see a 0.  Here is the code I have:

 

                If TypeOf oEnt Is AcadLWPolyline Then
                     If oEnt.Layer = USFLay Then
                        dblUSF = dblUSF + oEnt.Area / 144
                    Else
                        If oEnt.Layer = UNSFLay Then
                            dblUNSF = dblUNSF + oEnt.Area / 144
                        End If
                    End If
                End If

3 REPLIES 3
Message 2 of 4
doglips
in reply to: tony.ecord

I'm not exactly sure what variable is returning what but how 'bout something like this

 

If TypeOf oEnt Is AcadLWPolyline Then
  If oEnt.Layer = USFLay Then
   dblUSF = dblUSF + oEnt.Area / 144
  if dblusf < 1 then
   dblusf = 0
  end if
  Else
  If oEnt.Layer = UNSFLay Then
   dblUNSF = dblUNSF + oEnt.Area / 144
  if dblunsf < 1 then
   dblunsf = 0
  end if
  End If
 End If
 End If

Message 3 of 4
tony.ecord
in reply to: doglips

Doglips, you've helped me yet again.

 

It wasn't your solution exactly that worked, but it helped me figure out that I needed to add if-then-elses to my string formatting that comes after the snippet I posted.

 

Thanks again.

Message 4 of 4
doglips
in reply to: tony.ecord

Glad to help.
It doesn't matter how you get there... as long as you get there 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost