<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337471#M85683</link>
    <description>Hi Rob,&lt;BR /&gt;
&lt;BR /&gt;
    In your last response to Frank, you state that the Rnum2 variable is a&lt;BR /&gt;
string.  I got the impression from your first post that Cnt was an integer.&lt;BR /&gt;
Depending on what Cnt is declared as will affect the result.  For example,&lt;BR /&gt;
&lt;BR /&gt;
dim Cnt as Integer&lt;BR /&gt;
&lt;BR /&gt;
Cnt = Format(Mid$(Rnum2, 2), "000")&lt;BR /&gt;
&lt;BR /&gt;
will yield Cnt = 1 when Rnum2 = "A001"&lt;BR /&gt;
&lt;BR /&gt;
However,&lt;BR /&gt;
&lt;BR /&gt;
dim Cnt as String&lt;BR /&gt;
&lt;BR /&gt;
Cnt = Format(Mid$(Rnum2, 2), "000")&lt;BR /&gt;
&lt;BR /&gt;
will yield Cnt = "001" when Rnum2 = "A001"&lt;BR /&gt;
&lt;BR /&gt;
Hope this helps,&lt;BR /&gt;
&lt;BR /&gt;
David</description>
    <pubDate>Mon, 02 Apr 2001 13:26:39 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2001-04-02T13:26:39Z</dc:date>
    <item>
      <title>Format Function</title>
      <link>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337467#M85679</link>
      <description>&lt;DIV&gt;Can you use the Format Function on a variable that is declared as an &lt;BR /&gt;
integer?&amp;nbsp; If not, how can I get an Integer variable to hold the results of &lt;BR /&gt;
a string with the following code:&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rnum2 = txtStrtNum.Text&amp;nbsp;&amp;nbsp;'in this case &lt;BR /&gt;
txtstrtnum.text = A001&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Cnt = Mid$(Rnum2, 2, 4) 'Since &lt;BR /&gt;
the first two characters are zeros, Cnt changes it too an integer? and Cnt now = &lt;BR /&gt;
"1" and I want it to&amp;nbsp;= "001"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;How do I force Cnt to = "001"&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;Thanx,&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;Rob&lt;/DIV&gt;</description>
      <pubDate>Fri, 30 Mar 2001 16:11:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337467#M85679</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-03-30T16:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: Format Function</title>
      <link>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337468#M85680</link>
      <description>&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;You could make the string "A00" &amp;amp; Cnt for Cnt &lt;BR /&gt;
&amp;lt; 10, then "A0" for Cnt 10-99, etc.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;
style="BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;Rob Outman &amp;lt;&lt;A&gt;&lt;BR /&gt;
  href="mailto:routman@nakata.com"&amp;gt;routman@nakata.com&lt;/A&gt;&amp;gt; wrote in message &lt;BR /&gt;
  &lt;A&gt;&lt;BR /&gt;
  href="news:50FDEA3DC08B093D54473B0C99F614FD@in.WebX.maYIadrTaRb"&amp;gt;news:50FDEA3DC08B093D54473B0C99F614FD@in.WebX.maYIadrTaRb&lt;/A&gt;...&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Can you use the Format Function on a variable that is declared as an &lt;BR /&gt;
  integer?&amp;nbsp; If not, how can I get an Integer variable to hold the results &lt;BR /&gt;
  of a string with the following code:&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rnum2 = txtStrtNum.Text&amp;nbsp;&amp;nbsp;'in this case &lt;BR /&gt;
  txtstrtnum.text = A001&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Cnt = Mid$(Rnum2, 2, 4) &lt;BR /&gt;
  'Since the first two characters are zeros, Cnt changes it too an integer? and &lt;BR /&gt;
  Cnt now = "1" and I want it to&amp;nbsp;= "001"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;How do I force Cnt to = "001"&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Thanx,&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Rob&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Fri, 30 Mar 2001 17:06:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337468#M85680</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-03-30T17:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: Format Function</title>
      <link>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337469#M85681</link>
      <description>Assuming Rnum2 is a String variable and always in the format ANNN&lt;BR /&gt;
(alpha, numeric, numeric, numeric), Mid$(Rnum2, 2) wil return "001"&lt;BR /&gt;
(in the case of "A001").&lt;BR /&gt;
&lt;BR /&gt;
If you're not sure about the value being properly zero-padded,&lt;BR /&gt;
Format(Mid$(Rnum2, 2), "000") will return "001", even if the original&lt;BR /&gt;
text was "A1"&lt;BR /&gt;
&lt;BR /&gt;
Hope this helps.&lt;BR /&gt;
&lt;BR /&gt;
--&lt;BR /&gt;
http://www.acadx.com&lt;BR /&gt;
Win a free autographed copy of&lt;BR /&gt;
"AutoCAD 2000 VBA Programmer's Reference"&lt;BR /&gt;
by Joe Sutphin&lt;BR /&gt;
&lt;BR /&gt;
"Rob Outman" &lt;ROUTMAN&gt; wrote in message&lt;BR /&gt;
news:50FDEA3DC08B093D54473B0C99F614FD@in.WebX.maYIadrTaRb...&lt;BR /&gt;
Can you use the Format Function on a variable that is declared as an&lt;BR /&gt;
integer?  If not, how can I get an Integer variable to hold the&lt;BR /&gt;
results of a string with the following code:&lt;BR /&gt;
&lt;BR /&gt;
    Rnum2 = txtStrtNum.Text  'in this case txtstrtnum.text = A001&lt;BR /&gt;
    Cnt = Mid$(Rnum2, 2, 4) 'Since the first two characters are zeros,&lt;BR /&gt;
Cnt changes it too an integer? and Cnt now = "1" and I want it to =&lt;BR /&gt;
"001"&lt;BR /&gt;
&lt;BR /&gt;
How do I force Cnt to = "001"&lt;BR /&gt;
&lt;BR /&gt;
Thanx,&lt;BR /&gt;
&lt;BR /&gt;
Rob&lt;/ROUTMAN&gt;</description>
      <pubDate>Fri, 30 Mar 2001 18:28:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337469#M85681</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-03-30T18:28:09Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337470#M85682</link>
      <description>Hi guys,&lt;BR /&gt;
&lt;BR /&gt;
Thanx for the help.  Unfortunately I can not get them to work... at least&lt;BR /&gt;
not all the way.&lt;BR /&gt;
&lt;BR /&gt;
Frank,&lt;BR /&gt;
&lt;BR /&gt;
Yes, the Rnum2 variable is a string and will always be (ANNN) I could not&lt;BR /&gt;
get the following:&lt;BR /&gt;
&lt;BR /&gt;
Cnt = Mid$(Rnum2, 2)&lt;BR /&gt;
&lt;BR /&gt;
or&lt;BR /&gt;
&lt;BR /&gt;
Cnt = Format(Mid$(Rnum2, 2), "000")&lt;BR /&gt;
&lt;BR /&gt;
to equal "001" no matter what I tried.  I started a brand new module and&lt;BR /&gt;
tried it there too, no go.  Am I missing something?&lt;BR /&gt;
&lt;BR /&gt;
Mark,&lt;BR /&gt;
&lt;BR /&gt;
I did get yours to work but only until it came across the next digit in the&lt;BR /&gt;
loop.  I wrote the following IF THEN statements:&lt;BR /&gt;
&lt;BR /&gt;
If Cnt &amp;lt; 10 Then Rnum = Rnum &amp;amp; "00"&lt;BR /&gt;
' The above works fine until it gets above 9 then it adds a "0" to the front&lt;BR /&gt;
of the number and 'reads something like A0010&lt;BR /&gt;
&lt;BR /&gt;
If Cnt = 10 - 99 Then Rnum = Rnum &amp;amp; "0" 'Is this a valid statement?&lt;BR /&gt;
&lt;BR /&gt;
'The above works fine until it gets above 99 then it adds a "0" to the front&lt;BR /&gt;
of the number and 'reads something like A0100&lt;BR /&gt;
&lt;BR /&gt;
If Cnt &amp;gt; 100 Then Rnum = Rnum&lt;BR /&gt;
'I can't get above 100 to work at all.&lt;BR /&gt;
&lt;BR /&gt;
End If&lt;BR /&gt;
&lt;BR /&gt;
I did try them the other way around (Then Rnum = "00" &amp;amp; Rnum) but this just&lt;BR /&gt;
returns something like A1, A2, A3 etc...&lt;BR /&gt;
&lt;BR /&gt;
Anymore suggestions would be greatly appreciated.&lt;BR /&gt;
&lt;BR /&gt;
Thanx again guys,&lt;BR /&gt;
&lt;BR /&gt;
Rob&lt;BR /&gt;
&lt;BR /&gt;
"Frank Oquendo" &lt;FRANKO&gt; wrote in message&lt;BR /&gt;
news:BD0B3B45C22005D674959010D80E2357@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; Assuming Rnum2 is a String variable and always in the format ANNN&lt;BR /&gt;
&amp;gt; (alpha, numeric, numeric, numeric), Mid$(Rnum2, 2) wil return "001"&lt;BR /&gt;
&amp;gt; (in the case of "A001").&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; If you're not sure about the value being properly zero-padded,&lt;BR /&gt;
&amp;gt; Format(Mid$(Rnum2, 2), "000") will return "001", even if the original&lt;BR /&gt;
&amp;gt; text was "A1"&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Hope this helps.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; --&lt;BR /&gt;
&amp;gt; http://www.acadx.com&lt;BR /&gt;
&amp;gt; Win a free autographed copy of&lt;BR /&gt;
&amp;gt; "AutoCAD 2000 VBA Programmer's Reference"&lt;BR /&gt;
&amp;gt; by Joe Sutphin&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; "Rob Outman" &lt;ROUTMAN&gt; wrote in message&lt;BR /&gt;
&amp;gt; news:50FDEA3DC08B093D54473B0C99F614FD@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; Can you use the Format Function on a variable that is declared as an&lt;BR /&gt;
&amp;gt; integer?  If not, how can I get an Integer variable to hold the&lt;BR /&gt;
&amp;gt; results of a string with the following code:&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     Rnum2 = txtStrtNum.Text  'in this case txtstrtnum.text = A001&lt;BR /&gt;
&amp;gt;     Cnt = Mid$(Rnum2, 2, 4) 'Since the first two characters are zeros,&lt;BR /&gt;
&amp;gt; Cnt changes it too an integer? and Cnt now = "1" and I want it to =&lt;BR /&gt;
&amp;gt; "001"&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; How do I force Cnt to = "001"&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Thanx,&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Rob&lt;BR /&gt;
&amp;gt;&lt;/ROUTMAN&gt;&lt;/FRANKO&gt;</description>
      <pubDate>Mon, 02 Apr 2001 10:29:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337470#M85682</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-04-02T10:29:20Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337471#M85683</link>
      <description>Hi Rob,&lt;BR /&gt;
&lt;BR /&gt;
    In your last response to Frank, you state that the Rnum2 variable is a&lt;BR /&gt;
string.  I got the impression from your first post that Cnt was an integer.&lt;BR /&gt;
Depending on what Cnt is declared as will affect the result.  For example,&lt;BR /&gt;
&lt;BR /&gt;
dim Cnt as Integer&lt;BR /&gt;
&lt;BR /&gt;
Cnt = Format(Mid$(Rnum2, 2), "000")&lt;BR /&gt;
&lt;BR /&gt;
will yield Cnt = 1 when Rnum2 = "A001"&lt;BR /&gt;
&lt;BR /&gt;
However,&lt;BR /&gt;
&lt;BR /&gt;
dim Cnt as String&lt;BR /&gt;
&lt;BR /&gt;
Cnt = Format(Mid$(Rnum2, 2), "000")&lt;BR /&gt;
&lt;BR /&gt;
will yield Cnt = "001" when Rnum2 = "A001"&lt;BR /&gt;
&lt;BR /&gt;
Hope this helps,&lt;BR /&gt;
&lt;BR /&gt;
David</description>
      <pubDate>Mon, 02 Apr 2001 13:26:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337471#M85683</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-04-02T13:26:39Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337472#M85684</link>
      <description>Ok here is some more clarification.  I changed Cnt to a variable and it now&lt;BR /&gt;
works is I add a breakpoint and view the result.  But the only problem is&lt;BR /&gt;
after the loop runs, the Cnt value changes from say "001" to "1".  Is there&lt;BR /&gt;
a statement I can add to the code in the loop that will force the Cnt&lt;BR /&gt;
variable to retain the "001" value and then continue on?&lt;BR /&gt;
&lt;BR /&gt;
Thanx,&lt;BR /&gt;
&lt;BR /&gt;
Rob&lt;BR /&gt;
&lt;BR /&gt;
"David Moroni" &lt;DMORONI&gt; wrote in message&lt;BR /&gt;
news:7F8D73ED5B650F68F80E742A7B5532E3@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; Hi Rob,&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     In your last response to Frank, you state that the Rnum2 variable is a&lt;BR /&gt;
&amp;gt; string.  I got the impression from your first post that Cnt was an&lt;BR /&gt;
integer.&lt;BR /&gt;
&amp;gt; Depending on what Cnt is declared as will affect the result.  For example,&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; dim Cnt as Integer&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Cnt = Format(Mid$(Rnum2, 2), "000")&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; will yield Cnt = 1 when Rnum2 = "A001"&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; However,&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; dim Cnt as String&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Cnt = Format(Mid$(Rnum2, 2), "000")&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; will yield Cnt = "001" when Rnum2 = "A001"&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Hope this helps,&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; David&lt;BR /&gt;
&amp;gt;&lt;/DMORONI&gt;</description>
      <pubDate>Mon, 02 Apr 2001 14:33:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337472#M85684</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-04-02T14:33:36Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337473#M85685</link>
      <description>Hi Rob,&lt;BR /&gt;
&lt;BR /&gt;
    Your code has probably gone through several changes since you first&lt;BR /&gt;
posted your question.  Could you post your procedure with the latest&lt;BR /&gt;
changes?  This might help diagnose the problem.&lt;BR /&gt;
&lt;BR /&gt;
David</description>
      <pubDate>Tue, 03 Apr 2001 07:25:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337473#M85685</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-04-03T07:25:45Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337474#M85686</link>
      <description>Hi David,&lt;BR /&gt;
&lt;BR /&gt;
Here is the code as it is currently.  Just to warn you... It's pretty long.&lt;BR /&gt;
Basically, it goes through, has the user select a roomtag block, change the&lt;BR /&gt;
attribute value to the textbox value the user entered, adds one to the Cnt&lt;BR /&gt;
variable and then does the next one the user selects.  The first tag works&lt;BR /&gt;
fine, but after that the Cnt value changes (somehow) and then it leaves out&lt;BR /&gt;
the necessary 0's (zeros).  I can't figure this out.  Any guesses?&lt;BR /&gt;
&lt;BR /&gt;
&lt;SNIP&gt;&lt;BR /&gt;
Private Sub cmdRun_Click()&lt;BR /&gt;
&lt;BR /&gt;
Dim fType, fData, ss As AcadSelectionSet&lt;BR /&gt;
Dim varBlkattribs As Variant&lt;BR /&gt;
Dim strBlkAttribs As String&lt;BR /&gt;
Dim blkRef As AcadBlockReference&lt;BR /&gt;
Dim objBlkSelect As AcadSelectionSet&lt;BR /&gt;
Dim intarray() As Integer&lt;BR /&gt;
Dim attarry As AcadAttribute&lt;BR /&gt;
Dim Point(0 To 2) As Double&lt;BR /&gt;
Dim strArray As String&lt;BR /&gt;
Dim Acadblock As AcadBlockReference&lt;BR /&gt;
Dim Ent As AcadEntity&lt;BR /&gt;
Dim Pt As Variant&lt;BR /&gt;
Dim Cnt As Variant 'or Integer (variant works better)&lt;BR /&gt;
Dim rnum As String&lt;BR /&gt;
Dim rnum2 As String&lt;BR /&gt;
Dim Rnum3 As Variant&lt;BR /&gt;
Dim endResult As String&lt;BR /&gt;
Dim optcomp As String&lt;BR /&gt;
&lt;BR /&gt;
'Set a filter to search for all instances of the "Roomtag" block and apply&lt;BR /&gt;
the count to the ss 'variable.&lt;BR /&gt;
With ThisDrawing.Utility&lt;BR /&gt;
    Set ss = CreateSelectionSet()&lt;BR /&gt;
    BuildFilter fType, fData, 0, "INSERT", 2, "ROOMTAG"&lt;BR /&gt;
    ss.Select acSelectionSetAll, , , fType, fData&lt;BR /&gt;
'Prompt the user as to how many roomtags there are in the drawing.&lt;BR /&gt;
    .Prompt vbCr &amp;amp; "There are " &amp;amp; ss.Count &amp;amp; " Roomtags in this drawing."&lt;BR /&gt;
End With&lt;BR /&gt;
&lt;BR /&gt;
'hide the form&lt;BR /&gt;
Me.Hide&lt;BR /&gt;
&lt;BR /&gt;
'If the first letter in the textbox is an "A" then do the following&lt;BR /&gt;
If Left(txtStrtNum.Text, 1) = LCase("A") Then&lt;BR /&gt;
&lt;BR /&gt;
    rnum2 = txtStrtNum.Text&lt;BR /&gt;
    Cnt = Format(Mid$(rnum2, 2), "000")&lt;BR /&gt;
    rnum = Mid$(rnum2, 1, 1)&lt;BR /&gt;
    endResult = UCase(rnum) &amp;amp; Cnt&lt;BR /&gt;
&lt;BR /&gt;
On Error Resume Next&lt;BR /&gt;
If ss.Count &amp;gt; 0 Then&lt;BR /&gt;
    Do&lt;BR /&gt;
        'Have the user select the tags in order and udate them as they are&lt;BR /&gt;
selected.&lt;BR /&gt;
        ThisDrawing.Utility.GetEntity Ent, Pt, "Select the roomtags in&lt;BR /&gt;
order: "&lt;BR /&gt;
        Ent.Highlight True&lt;BR /&gt;
        If Err Then&lt;BR /&gt;
            If ThisDrawing.GetVariable("errno") = "7" Then&lt;BR /&gt;
                Err.Clear&lt;BR /&gt;
            Else&lt;BR /&gt;
                Err.Clear&lt;BR /&gt;
                Exit Do&lt;BR /&gt;
            End If&lt;BR /&gt;
        End If&lt;BR /&gt;
        'check to see if the entity selected is a block&lt;BR /&gt;
        If TypeOf Ent Is AcadBlockReference Then&lt;BR /&gt;
            Set blkRef = Ent&lt;BR /&gt;
            'check to see if the block is named "Roomtag"&lt;BR /&gt;
            If blkRef.Name = "ROOMTAG" Then&lt;BR /&gt;
                'Check to see if the roomtag has attributes.&lt;BR /&gt;
                If blkRef.HasAttributes Then&lt;BR /&gt;
                    varBlkattribs = blkRef.GetAttributes&lt;BR /&gt;
                    varBlkattribs(0).TextString = endResult&lt;BR /&gt;
                End If&lt;BR /&gt;
                End If&lt;BR /&gt;
            'add 1 (one) to each roomtag as each one is selected.&lt;BR /&gt;
            Cnt = Cnt + 1&lt;BR /&gt;
            endResult = UCase(rnum &amp;amp; (Cnt))&lt;BR /&gt;
            Else&lt;BR /&gt;
            'If the entity selected is not a roomtag block then send the&lt;BR /&gt;
following message.&lt;BR /&gt;
            MsgBox "The Object You Selected Is Not A Roomtag."&lt;BR /&gt;
            End If&lt;BR /&gt;
        Ent.Highlight False&lt;BR /&gt;
        Loop&lt;BR /&gt;
End If&lt;BR /&gt;
Ent.Highlight False&lt;BR /&gt;
&lt;BR /&gt;
'If there is no value "A" in the textbox, then do the folowing:&lt;BR /&gt;
'The folowing section works with no problems.&lt;BR /&gt;
Else&lt;BR /&gt;
    Cnt = txtStrtNum.Text&lt;BR /&gt;
End If&lt;BR /&gt;
&lt;BR /&gt;
On Error Resume Next&lt;BR /&gt;
If ss.Count &amp;gt; 0 Then&lt;BR /&gt;
    Do&lt;BR /&gt;
        'Have the user select the tags in order and udate them as they are&lt;BR /&gt;
selected.&lt;BR /&gt;
        ThisDrawing.Utility.GetEntity Ent, Pt, "Select the roomtags in&lt;BR /&gt;
order: "&lt;BR /&gt;
        Ent.Highlight True&lt;BR /&gt;
        If Err Then&lt;BR /&gt;
            If ThisDrawing.GetVariable("errno") = "7" Then&lt;BR /&gt;
                Err.Clear&lt;BR /&gt;
            Else&lt;BR /&gt;
                Err.Clear&lt;BR /&gt;
                Exit Do&lt;BR /&gt;
            End If&lt;BR /&gt;
        End If&lt;BR /&gt;
        'check to see if the entity selected is a block&lt;BR /&gt;
        If TypeOf Ent Is AcadBlockReference Then&lt;BR /&gt;
            Set blkRef = Ent&lt;BR /&gt;
            'check to see if the block is named "Roomtag"&lt;BR /&gt;
            If blkRef.Name = "ROOMTAG" Then&lt;BR /&gt;
                'Check to see if the roomtag has attributes.&lt;BR /&gt;
                If blkRef.HasAttributes Then&lt;BR /&gt;
                    varBlkattribs = blkRef.GetAttributes&lt;BR /&gt;
                    varBlkattribs(0).TextString = Cnt&lt;BR /&gt;
                End If&lt;BR /&gt;
                End If&lt;BR /&gt;
            'add 1 (one) to each roomtag as each one is selected.&lt;BR /&gt;
            Cnt = Cnt + 1&lt;BR /&gt;
            Else&lt;BR /&gt;
            'If the entity selected is not a roomtag block then send the&lt;BR /&gt;
following message.&lt;BR /&gt;
            MsgBox "The Object You Selected Is Not A Roomtag."&lt;BR /&gt;
            End If&lt;BR /&gt;
        Ent.Highlight False&lt;BR /&gt;
    Loop&lt;BR /&gt;
End If&lt;BR /&gt;
Ent.Highlight False&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Thanx in advance for any suggestions you may have.&lt;BR /&gt;
&lt;BR /&gt;
Rob&lt;BR /&gt;
&lt;BR /&gt;
"David Moroni" &lt;DMORONI&gt; wrote in message&lt;BR /&gt;
news:396F057CD9704DA571DF6A05834A8E4D@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; Hi Rob,&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     Your code has probably gone through several changes since you first&lt;BR /&gt;
&amp;gt; posted your question.  Could you post your procedure with the latest&lt;BR /&gt;
&amp;gt; changes?  This might help diagnose the problem.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; David&lt;BR /&gt;
&amp;gt;&lt;/DMORONI&gt;&lt;/SNIP&gt;</description>
      <pubDate>Tue, 03 Apr 2001 07:46:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337474#M85686</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-04-03T07:46:57Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337475#M85687</link>
      <description>Hi Rob,&lt;BR /&gt;
&lt;BR /&gt;
    Unfortunately, I have to leave town this afternoon, so I have just&lt;BR /&gt;
glanced at the code you posted.  However, I think the problem is how you are&lt;BR /&gt;
handling the Cnt variable.  Cnt is used with both string and numerical&lt;BR /&gt;
operations.  Here's my suggestion on how to acheive what you want.  First,&lt;BR /&gt;
declare Cnt as an Integer.&lt;BR /&gt;
&lt;BR /&gt;
Dim Cnt as Integer&lt;BR /&gt;
&lt;BR /&gt;
Then change&lt;BR /&gt;
&lt;BR /&gt;
Cnt = Format(Mid$(rnum2, 2), "000")&lt;BR /&gt;
&lt;BR /&gt;
to&lt;BR /&gt;
&lt;BR /&gt;
Cnt = Val(Mid$(rnum2, 2))&lt;BR /&gt;
&lt;BR /&gt;
then do your renumbering manipulation.  When you are ready to build the&lt;BR /&gt;
endResult variable, use a Select Case similar to&lt;BR /&gt;
&lt;BR /&gt;
Select Case Cnt&lt;BR /&gt;
&lt;BR /&gt;
    Case 0 to 9&lt;BR /&gt;
&lt;BR /&gt;
        endResult = UCase(rnum) &amp;amp; "00" &amp;amp; Cnt&lt;BR /&gt;
&lt;BR /&gt;
    Case 10 to 99&lt;BR /&gt;
&lt;BR /&gt;
        endResult = UCase(rnum) &amp;amp; "0" &amp;amp; Cnt&lt;BR /&gt;
&lt;BR /&gt;
    Case 100 to 999&lt;BR /&gt;
&lt;BR /&gt;
        endResult = UCase(rnum) &amp;amp; Cnt&lt;BR /&gt;
&lt;BR /&gt;
    Case &amp;gt; 999&lt;BR /&gt;
&lt;BR /&gt;
        (Some error handling code here)&lt;BR /&gt;
&lt;BR /&gt;
End Select&lt;BR /&gt;
&lt;BR /&gt;
This way, Cnt is always referred to as an integer and the formatting of the&lt;BR /&gt;
string variable is handled in the Select Case.&lt;BR /&gt;
&lt;BR /&gt;
Hope this helps,&lt;BR /&gt;
&lt;BR /&gt;
David</description>
      <pubDate>Tue, 03 Apr 2001 11:03:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337475#M85687</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-04-03T11:03:37Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337476#M85688</link>
      <description>Finally it works!!! Your suggestion to use a select case to build the&lt;BR /&gt;
endResult clued me in.  I had to build the endResult inside of the Do Loop.&lt;BR /&gt;
It works perfectly now!!!  There is one minor flaw that I am going to work&lt;BR /&gt;
on to perfect it and then it will finally be done.  This macro has been the&lt;BR /&gt;
hardest one I have tried to create yet... but it has been worth it.&lt;BR /&gt;
&lt;BR /&gt;
The good thing is that I still love this programming stuff!!!&lt;BR /&gt;
&lt;BR /&gt;
Thanx for all of your help David.  And thanx to everyone else for the&lt;BR /&gt;
suggestions.&lt;BR /&gt;
&lt;BR /&gt;
Rob&lt;BR /&gt;
&lt;BR /&gt;
"David Moroni" &lt;DMORONI&gt; wrote in message&lt;BR /&gt;
news:26DD81DACA3679BC83F7AEA74ACC3234@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; Hi Rob,&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     Unfortunately, I have to leave town this afternoon, so I have just&lt;BR /&gt;
&amp;gt; glanced at the code you posted.  However, I think the problem is how you&lt;BR /&gt;
are&lt;BR /&gt;
&amp;gt; handling the Cnt variable.  Cnt is used with both string and numerical&lt;BR /&gt;
&amp;gt; operations.  Here's my suggestion on how to acheive what you want.  First,&lt;BR /&gt;
&amp;gt; declare Cnt as an Integer.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Dim Cnt as Integer&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Then change&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Cnt = Format(Mid$(rnum2, 2), "000")&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; to&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Cnt = Val(Mid$(rnum2, 2))&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; then do your renumbering manipulation.  When you are ready to build the&lt;BR /&gt;
&amp;gt; endResult variable, use a Select Case similar to&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Select Case Cnt&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     Case 0 to 9&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;         endResult = UCase(rnum) &amp;amp; "00" &amp;amp; Cnt&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     Case 10 to 99&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;         endResult = UCase(rnum) &amp;amp; "0" &amp;amp; Cnt&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     Case 100 to 999&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;         endResult = UCase(rnum) &amp;amp; Cnt&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     Case &amp;gt; 999&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;         (Some error handling code here)&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; End Select&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; This way, Cnt is always referred to as an integer and the formatting of&lt;BR /&gt;
the&lt;BR /&gt;
&amp;gt; string variable is handled in the Select Case.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Hope this helps,&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; David&lt;BR /&gt;
&amp;gt;&lt;/DMORONI&gt;</description>
      <pubDate>Tue, 03 Apr 2001 12:46:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337476#M85688</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-04-03T12:46:22Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337477#M85689</link>
      <description>&lt;SNORKLE&gt;&lt;BR /&gt;
&lt;BR /&gt;
| It works perfectly now!!!  There is one minor flaw that I am going to work&lt;BR /&gt;
| on to perfect it and then it will finally be done.&lt;BR /&gt;
&lt;BR /&gt;
Perfection is so transient...&lt;/SNORKLE&gt;</description>
      <pubDate>Tue, 03 Apr 2001 12:51:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/format-function/m-p/337477#M85689</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-04-03T12:51:09Z</dc:date>
    </item>
  </channel>
</rss>

