Let's look at the "Align.vbp" project from your "\Microsoft Visual Basic\samples\align" directory:


In order to understand how this program works, we could either go through the following .frm, .bas and three .cls files....

About.frm Private Sub Command1_Click() Unload Me

End Sub

Private Sub Form_Activate() SetFocus

End Sub

Private Sub Form_Load()

With Screen Left = (.Width - Width) / 2 Top = (.Height - Height) / 2 End With Text1.Text = "

Select all the controls on a form you wish to align to each other, then use the Align menu item in the Add-Ins menu to select a type of alignment. If a selected control does not support the Top, Left, Height or Width properties, it will not be aligned. The selected controls will be aligned to the control with an edge nearest to the specified side of the Form. For example, Align Left will align the left edge of all selected controls with the left edge of the selected control whose left edge is nearest to the left side of the form."

End Sub

Main.bas #If Win16 Then Declare Function WritePrivateProfileString Lib "KERNEL" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal FileName$) As Integer Declare Function GetPrivateProfileString Lib "KERNEL" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal ReturnString$, ByVal NumBytes As Integer, ByVal FileName$) As Integer #Else Declare Function WritePrivateProfileString Lib "Kernel32" Alias "WritePrivateProfileStringA" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal FileName$) As Long Declare Function GetPrivateProfileString Lib "Kernel32" Alias "GetPrivateProfileStringA" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal ReturnString$, ByVal NumBytes As Long, ByVal FileName$) As Long #End If

Sub Main() Dim ReturnString As String '--- Check to see if we are in the VB.INI File. If not, Add ourselves to the INI file #If Win16 Then Section$ = "Add-Ins16" #Else Section$ = "Add-Ins32" #End If 'Check to see if the Align.Connector entry is already in the VB.INI file. Add if not. ReturnString = String$(255, Chr$(0)) GetPrivateProfileString Section$, "Align.Connector", "NotFound", ReturnString, Len(ReturnString) + 1, "VB.INI" If Left(ReturnString, InStr(ReturnString, Chr(0)) - 1) = "NotFound" Then WritePrivateProfileString Section$, "Align.Connector", "0", "VB.INI" End If End Sub

Align.cls 'This class is used to connect this addin to the Visual Basic 'design environment. It must the Public property set to True, and the 'Instancing property set to '2 - Createable MultiUse' (recommended for addins) 'or '1 - Createble SingleUse' Option Explicit 'Storage for the menu and menuline objects created when the add-in adds its own menu 'and menulines to Visual Basic Const AlignLeft = 0 Const AlignRight = 1 Const AlignTop = 2 Const AlignBottom = 3 Const AlignAbout = 4 Const SizeWidth = 5 Const SizeHeight = 6 Const SizeBoth = 7

Dim AlignMenu As VBIDE.SubMenu Dim SizeMenu As VBIDE.SubMenu Dim MenuLines(AlignLeft To SizeBoth) As VBIDE.MenuLine Dim AlignHandler(AlignLeft To AlignBottom) As AlignAll Dim SizeHandler(SizeWidth To SizeBoth) As SizeAll Dim ConnectID(AlignLeft To SizeBoth) As Long Dim VBInstance As VBIDE.Application

Sub ConnectAddIn(VBDriverInstance As VBIDE.Application) Dim i% 'This method is called when this add-in is installed in an instance 'of Visual Basic. Choose "Align Sample Add-In" from the Add-In manager 'on another instance of VB. VBInstance will be the object representation 'of the instance of Visual Basic which installed the add-in. To change 'the name of the addin in the addin manager, select the Align project in the 'object browser, click on the Connector class, and choose Options.

'Save the instance of Visual Basic so we can refer to it later. Set VBInstance = VBDriverInstance With VBInstance.AddInMenu.MenuItems 'Add our Align menu and menu lines to the Visual Basic Add-In menu. Set AlignMenu = .AddMenu("A&lign") With AlignMenu.MenuItems Set MenuLines(AlignLeft) = .Add("&Left Align") Set MenuLines(AlignRight) = .Add("&Right Align") Set MenuLines(AlignTop) = .Add("&Top Align") Set MenuLines(AlignBottom) = .Add("&Bottom Align") Set MenuLines(AlignAbout) = .Add("About...") End With 'Add our Align menu and menu lines to the Visual Basic Add-In menu. Set SizeMenu = .AddMenu("Si&ze") With SizeMenu.MenuItems Set MenuLines(SizeWidth) = .Add("&Width") Set MenuLines(SizeHeight) = .Add("&Height") Set MenuLines(SizeBoth) = .Add("&Both") End With End With 'Connect the corresponding event handler object to the correct menu line. For i% = AlignLeft To AlignBottom 'Create a new handler for each direction. Set AlignHandler(i%) = New AlignAll 'Save the ID for each connected event. ConnectID(i%) = MenuLines(i%).ConnectEvents(AlignHandler(i%)) 'Pass the VBInstance to the child objects. Set AlignHandler(i%).VBInstance = VBInstance Next i% 'Set the AfterClick handler for the about box. ConnectID(AlignAbout) = MenuLines(AlignAbout).ConnectEvents(Me) 'Connect the SizeHandler events. Same as hooking up Align events. For i% = SizeWidth To SizeBoth Set SizeHandler(i%) = New SizeAll ConnectID(i%) = MenuLines(i%).ConnectEvents(SizeHandler(i%)) Set SizeHandler(i%).VBInstance = VBInstance Next i% 'Initialize the directional Align instances. AlignHandler(AlignLeft).MainProp = "Left" AlignHandler(AlignRight).MainProp = "Left" AlignHandler(AlignRight).ShiftProp = "Width" AlignHandler(AlignTop).MainProp = "Top" AlignHandler(AlignBottom).MainProp = "Top" AlignHandler(AlignBottom).ShiftProp = "Height" 'Initialize SizeFlags on Size instances. SizeHandler(SizeWidth).SizeFlags = 1 SizeHandler(SizeHeight).SizeFlags = 2 SizeHandler(SizeBoth).SizeFlags = 3 End Sub

Sub DisconnectAddIn(Mode As Integer) Dim i% Dim mnuItems As VBIDE.MenuItems 'Remove AlignMenu items. Set mnuItems = AlignMenu.MenuItems For i% = AlignLeft To AlignAbout 'Disconnect the event handlers from the menu lines MenuLines(i%).DisconnectEvents ConnectID(i%) 'Remove the menu and menu lines we installed in Visual Basic mnuItems.Remove MenuLines(i%) Next i% 'Remove SizeMenu items. Set mnuItems = SizeMenu.MenuItems For i% = SizeWidth To SizeBoth MenuLines(i%).DisconnectEvents ConnectID(i%) mnuItems.Remove MenuLines(i%) Next i% 'Remove items from Addins menu. With VBInstance.AddInMenu.MenuItems .Remove AlignMenu .Remove SizeMenu End With End Sub

'Use this class to provide an AfterClick handler for About... Public Sub AfterClick() About.Show vbModal End Sub

AlignAll.cls 'Instances of this class handle all Alignment events. 'This class does not need its Instancing or Public 'properties set.

Option Explicit Public MainProp As String 'Left or Top Public ShiftProp As String 'Width or Height Public VBInstance As VBIDE.Application

Public Sub AfterClick() Dim TheseControls As VBIDE.SelectedControlTemplates 'Using 'As Object' for collection iterator is faster cross process. Dim Control As Object 'VBIDE.ControlTemplate Dim bDoShift As Boolean Dim CheckValue As Long Dim tmpValue As Long Dim Controls() As VBIDE.ControlTemplate 'Don't cycle twice through collection Dim i%, iControlCount As Integer 'Shift properties are Height and Width. bDoShift will be true for 'Bottom and Right alignment. bDoShift = Len(ShiftProp) If Not bDoShift Then CheckValue = 99999 'Defaults to 0 for a shifted property Set TheseControls = VBInstance.ActiveProject.ActiveForm.SelectedControlTemplates 'If a property access fails, then just ignore it. On Error Resume Next iControlCount = TheseControls.Count If iControlCount < 2 Then Exit Sub 'Nothing to do ReDim Controls(iControlCount - 1) 'Scan all the selected controls, checking for the best value to align to. For Each Control In TheseControls 'Keep a reference to the Control for the second pass through the collection. Set Controls(i%) = Control If bDoShift Then 'Right and Bottom alignment With Controls(i%).Properties 'Use the typed object for fastest performance. tmpValue = .Item(MainProp) + .Item(ShiftProp) If tmpValue > CheckValue Then CheckValue = tmpValue End With Else 'Left and Top alignment. With Controls(i%).Properties(MainProp) If .Value < CheckValue Then CheckValue = .Value End With End If i% = i% + 1 'Increment to maintain the position in the collection. Next 'Use the best value found on the first pass to align each control. For i% = 0 To iControlCount - 1 If bDoShift Then 'Right and Bottom alignment With Controls(i%).Properties .Item(MainProp) = CheckValue - .Item(ShiftProp).Value End With Else 'Left and Top alignment Controls(i%).Properties(MainProp) = CheckValue End If Next i% End Sub

SizeAll.cls Option Explicit

Private Const WidthProp = "Width" Private Const HeightProp = "Height" Public SizeFlags As Integer '1=Width, 2=Height, 3=Both Public VBInstance As VBIDE.Application

Public Sub AfterClick() Dim ControlIterator As Object Dim Control As VBIDE.ControlTemplate Dim NewWidth As Long Dim NewHeight As Long Dim bHaveNewValues As Boolean 'If a property access fails, then just ignore it. On Error Resume Next bHaveNewValues = False For Each ControlIterator In VBInstance.ActiveProject.ActiveForm.SelectedControlTemplates Set Control = ControlIterator With Control.Properties If bHaveNewValues Then If SizeFlags And 1 Then .Item(WidthProp) = NewWidth If SizeFlags And 2 Then .Item(HeightProp) = NewHeight Else If SizeFlags And 1 Then NewWidth = .Item(WidthProp) If SizeFlags And 2 Then NewHeight = .Item(HeightProp) bHaveNewValues = True End If End With Next End Sub

Or... we could have a clear overview of the program's underlying object structure in 3 easy steps using With Class 3.1!

#1: In With Class, we set our preference to Visual Basic

#2: Now we use With Class's utility to reverse entire directory of the project.

#3: Then we choose we aspects of the program's structure we would like to illustrate...

And in just seconds, we have a clear picture of the whole program's structure! (represented here in UML format).

.

As you can see, each class with it's methods, properties, has been clearly laid out - along with it's relationships to all of the other classes defined in the program, although there are no class relationships in this project to see. Now, you could interact with this diagram, changes relations, structure, and code; or simply use the diagram for documentation purposes. And when you're done, you can use With Class's powerful scripting language to generate new code, in any language, from the changes you've made!


free cialis submit=free cialis cialis com cialis order java.js buy cheap cialis online cialis exchange link cialis tadalafil american express viagra cialis buy cialis link mycialsnowprohostingcom onlinehtml cialis impotence drug eli lilly co cialis without prescription in detroit area why cialis buy cialis link onlinehtm pharmacyrxfreewebtoolscom cialis in south africa do u take cialis everyday add cialis url cialis and manufacturer cialis muncie indiana how to stop viagra cialis spam black buy casino cialis diet followup gambling jack low online order phentermine poker post viagra cialis comparison levitra cialis online sales mexican cialis boelolokeepkidshealthycom cialis link cialis day next cialis purchase mixing cialis with effexor bulk cialis and viagra sold world wide on line cialis discount save cialis story safest of cialis levitra viagra buy cialis href newopasblogdrivecom cialis en venezuela cialis western open tee times viagra and cialis cheap buy cialis link onlinecolnu cialis europe viagra cialis submit=cialis should i buy cialis online buy cialis amsterdam cialis dose cialis tablet sildenafil cialis generico buy cialis cialisfunsurforg onlinehtml cialis drug impotence cialis testimonials sitemap1 buy cialis no prescription cialis for order cialis side effects order cialis buy cialis dreampharmaceuticals cialis drug cialis peak serum time half life pill cutters for cialis blindness cialis cialis dysfunction erectile cialis pill low cost generic cialis blogid buy casino cialis inurl order phentermine poker viagra cialis compare viagra cialis soft tabs den haag results of comparisons of viagra and cialis buy cialis in uk cialis en espanol cialis prescriptions map buy cheap cialis cialis link onlineinfo cialis cost low cialis online sale mixing viagra and cialis black buy casino cialis diet followup gambling jack order phentermine poker viagra cialis cheapest online prices cialis news information about cialis and livetra black buy casino cialis diet gambling jack online order phentermine poker tag viagra xhtml cialis class action suit cialis open ticket western order cialis online black buy casino cialis diet holdem jack online order phentermine poker tag texas viagra xhtml cialis comment info personal remember cialis order in south africa is cialis over the counter drug black casino cialis diet followup gambling health jack phentermine poker viagra cialis company cialis on line generic soft tab cialis better erections by combining cialis and viagra cialis attorney ohio cialis melt tabs how does cialis work black buy casino cheap cialis diet followup gambling health jack online order phentermine poker viagra cialis black box warnings cialis mexico online how to get best results with cialis archive buy cialis cialis discount generic cialis online purchase how viagra cialis levitra work black buy casino cialis diet followup gambling jack online order phentermine poker viagra cialis cedar park cialis mg index best cialis generic price cialis and no prescription required cialis link pharmacyrawcsorg generic cialis online best place to get totally free viagra or cialis samples cialis and venous leak