Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm fairly new to VBA, specifically working with multiple subs and functions. My question is how do you transfer a variable/ integer back to the main sub? Here is an example of what I'm trying to do, but it resets the value "i" every time it enters a new sub.
Public Sub Main Dim oAss As AssemblyDocument = ThisApplication.ActiveDocument Dim oBOM As BOM = oAss.ComponentDefinition.BOM oBOM.StructuredViewEnabled = True oBOM.StructuredViewFirstLevelOnly = False Dim oBOMView As BOMView = oBOM.BOMViews.Item("Structured") Dim oRow As BOMRow For Each oRow In oBOMView.BOMRows i = cellRow(i) If Not oRow.ChildRows Is Nothing Call oChildRow(oRow, i) End If Next MessageBox.Show(i) End Sub Public Sub oChildRow(oRow As BOMRow, i As Integer) For Each oRow In oRow.ChildRows i = cellRow(i) If Not oRow.ChildRows Is Nothing Call oChildRow(oRow, i) End If Next End Sub Public Function cellRow(i As Integer) i = i + 1 Return i End Function
Solved! Go to Solution.