VBA - Using IF and selection s
I decided that I wanted to understand how to use 'If Then Else' statements, so my first task was to scan the drawing for circles and then have a statement on the command prompt that lets me know whether there are or arent.Above, in the code, you can see I have made a selection set that selects all the objects in a drawing. I then want to ask if there are any circles present in that selection set and then insert two lines of code which will be the answer to my question.
Can anyone advise, please? If sset1Obj.Count0 Then Something like this:
Sub ScanForCircles()Dim sCol As AcadSelectionSetsDim sset1Obj As AcadSelectionSetDim fTyp(0 To 0) As IntegerDim fDat(0 To 0) As VariantSet sCol = ThisDrawing.SelectionSetsOn Error Resume NextsCol.Item("SSET1").DeleteSet sset1Obj = sCol.Add("SSET1")fTyp(0) = 0fDat(0) = "CIRCLE"sset1Obj.Select acSelectionSetAll, , , fTyp, fDatMsgBox "There is " & sset1Obj.Count & " circles."sset1Obj.DeleteSet sset1Obj = NothingEnd Sub
That's great again, thanks.
Just a quick question, mate:
I Understand what the 'MsgBox' represents but I don't fully understand what the quote marks represent. Obviously the ones at either end are essential, but the ones in-between the text I am unsure exactly how they work in VBA along with the '&' aswell.
Can you explain, please? I can try and explain. A message box feeds a string to the screen via a dialog box. What is shown is a concatenation (joining) of a string. It shows a string, denoted by "There is " and then it is joining (&) it to a string value (actually a integer that VB converts to a string) sset1Obj.Count and then joining (&) another string to that " circles." WHat you end up with is a message box that shows "There is 2 circles" when the selection set has two items in it.
页:
[1]