Jump to content

Recommended Posts

Posted (edited)

declaring a public variable, this is the syntax i used... i cant get it to keep the variable public. it just loses the value after the sub is ran

 

here is what i have

 

Public m_letter As String, m_number As String
'end public varible declaration


Sub MRevs()
   Dim gpCode(1) As Integer
   Dim dataValue(1) As Variant
   Dim SS_WFrev As AcadSelectionSet
   
   SS_delete 1
   
   Set SS_WFrev = ThisDrawing.SelectionSets.Add("SS_WFrev")
       gpCode(0) = 0: dataValue(0) = "INSERT"
       gpCode(1) = 2: dataValue(1) = "WFREV"
       
       SS_WFrev.Select acSelectionSetAll, , , gpCode, dataValue
       
       Dim Cur_Blk As AcadBlockReference
       Dim Blk_Atts() As AcadAttributeReference
       Dim Cur_att As AcadAttributeReference
       Dim i As Integer, n As Integer
       
       For i = 0 To SS_WFrev.Count - 1
           Set Cur_Blk = SS_WFrev.Item(i)
           Blk_Atts = Cur_Blk.GetAttributes
           
           For n = 0 To UBound(Blk_Atts)
               Set Cur_att = Blk_Atts(n)
               
               If Cur_att.TagString = "REVNO" Then
               
                   If IsNumeric(Cur_att.TextString) Then
                       If Cur_att.TextString > m_number Then
                           m_number = Cur_att.TextString
                       End If
                   Else
                       If Cur_att.TextString > m_letter Then
                           m_letter = Cur_att.TextString
                       End If
                   End If
           
               End If
           
           Next n
           
       Next i
End Sub


Sub changerevtri()
   Dim gpCode(1) As Integer
   Dim dataValue(1) As Variant
   Dim SS_Revtag As AcadSelectionSet
   
   SS_delete 1
   
   Set SS_Revtag = ThisDrawing.SelectionSets.Add("SS_Revtag")
       gpCode(0) = 0: dataValue(0) = "INSERT"
       gpCode(1) = 2: dataValue(1) = "revtag"
       
       SS_Revtag.Select acSelectionSetAll, , , gpCode, dataValue
       
       Dim Cur_Blk As AcadBlockReference
       Dim Blk_Atts() As AcadAttributeReference
       Dim Cur_att As AcadAttributeReference
       Dim i As Integer, n As Integer
       
       For i = 0 To SS_Revtag.Count - 1
           Set Cur_Blk = SS_Revtag.Item(i)
           Blk_Atts = Cur_Blk.GetAttributes
           
           For n = 0 To UBound(Blk_Atts)
               Set Cur_att = Blk_Atts(n)
               
               If Cur_att.TagString = "REV#" Then
                   Cur_att.TextString = m_number
               End If
           
           Next n
       
       Next i
   Application.Update
End Sub

Edited by btraemoore
Posted

You should leave the question in place and post the answer too. That way others could learn from you.

Posted
You should leave the question in place and post the answer too. That way others could learn from you.

 

Glad you worked up :)

Posted

Okay, i figured out my problem. when i set the pubic variables i set them in between two different subs. To have your variables public and accessible they have to be at the very top of the module you are working on... above all subs just like the example coding. ;)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...