Option Explicit Dim varLargestValue Sub X ' Some code Call FindLargestValue ' Show to largest value from the sub being called... Msgbox varLargestValue ' Some Code End Sub Sub FindLargestValue Dim strFileName2 strFileName2 = varAXFFileName_2 '++ open the selected AXF file Dim pDS6 Set pDS6 = OpenAXF(strFileName2) If (pDS6 Is Nothing) Then Console.Print "Open DataSource failed" Exit Sub End If ' Set up recordset query Dim pRS6 Set pRS6 = pDS6.Execute("SELECT MAX(UNIQUEID2) AS MaximumID FROM Outfalls") '++ step through the records and output the first attribute to the Console window pRS6.MoveFirst Do While Not pRS6.EOF MaxID = (pRS6("MaximumID").value) pRs6.MoveNext Loop varLargestValue = MaxID Msgbox varLargestValue ' Close Recordset pRS6.Close Set pRS6 = Nothing End Sub
Option Explicit Dim varLargestValue Sub Something ' snip ' Get the largest value Dim largestValue largestValue = 0 Call FindLargestValue(largestValue) varLargestValue = largestValue ' snip End Sub Sub FindLargestValue(varlargestValue) Dim MaxID Dim strFileName2 strFileName2 = varAXFFileName_2 '++ open the selected AXF file Dim pDS6 Set pDS6 = OpenAXF(strFileName2) If (pDS6 Is Nothing) Then Console.Print "Open DataSource failed" Exit Sub End If ' Set up recordset query Dim pRS6 Set pRS6 = pDS6.Execute("SELECT MAX(UNIQUEID2) AS MaximumID FROM Outfalls") ' Move first pRS6.MoveFirst ' Loop recordset and get number of records Do While Not pRS6.EOF MaxID = (pRS6("MaximumID").value) pRs6.MoveNext Loop varLargestValue = MaxID ' Clear Variables MaxID = "" ' Close Recordset pRS6.Close Set pRS6 = Nothing End Sub
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.