+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Full Member
    Discipline
    Electrical
    btraemoore's Discipline Details
    Occupation
    Electrical Designer
    Discipline
    Electrical
    Using
    Electrical 2012
    Join Date
    Apr 2012
    Location
    Houston
    Posts
    55

    Default declaration of a public varible

    Registered forum members do not see this ad.

    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

    Code:
    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
    Last edited by btraemoore; 9th May 2012 at 01:29 pm.

  2. #2
    Super Moderator fuccaro's Avatar
    Using
    AutoCAD 2006
    Join Date
    Nov 2002
    Location
    Romania, Marosvasarhely
    Posts
    3,540

    Default

    You should leave the question in place and post the answer too. That way others could learn from you.
    It's nice to be nice, but sometimes is nicer to be evil!.
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.

  3. #3
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,586

    Default

    Quote Originally Posted by fuccaro View Post
    You should leave the question in place and post the answer too. That way others could learn from you.
    Glad you worked up
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

  4. #4
    Full Member
    Discipline
    Electrical
    btraemoore's Discipline Details
    Occupation
    Electrical Designer
    Discipline
    Electrical
    Using
    Electrical 2012
    Join Date
    Apr 2012
    Location
    Houston
    Posts
    55

    Default

    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.

  5. #5
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,932

    Default

    Registered forum members do not see this ad.

    "Potential has a shelf life." - Margaret Atwood

Similar Threads

  1. Alternative coordinate declaration VB
    By 16horse in forum .NET, ObjectARX & VBA
    Replies: 0
    Last Post: 15th Dec 2010, 05:32 pm
  2. system varible settings
    By kingisland99762 in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 29th Jan 2010, 10:35 pm
  3. A simple .dcl probblem, Useign a varible
    By flowerrobot in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 5th Apr 2009, 11:25 pm
  4. Public Health
    By GAZZA in forum MEP
    Replies: 0
    Last Post: 22nd Oct 2008, 12:10 pm
  5. The Joy of an E-Public life
    By Temporary Creature in forum Feedback
    Replies: 2
    Last Post: 2nd May 2006, 08:22 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts