How do you autoincrement a variable name

G

Guest

I am interested in dumping some results from a collection I have into a group
of variables. I have a counter that loops but I don't know how to use the
counter to determine my variable names.

Here is my code...



Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols

Namespace CiscoSwitch
Public Class SwitchInterfaces
Public SwitchPort1 As String
Public SwitchPort2 As String
Public SwitchPort3 As String
Public SwitchPort4 As String
Public SwitchPort5 As String
Public SwitchPort6 As String
Public SwitchPort7 As String
Public SwitchPort8 As String
Public SwitchPort9 As String
Public SwitchPort10 As String
Public SwitchPort11 As String
Public SwitchPort12 As String
Public SwitchPort13 As String
Public SwitchPort14 As String
Public SwitchPort15 As String
Public SwitchPort16 As String
Public SwitchPort17 As String
Public SwitchPort18 As String
Public SwitchPort19 As String
Public SwitchPort20 As String
Public SwitchPort21 As String
Public SwitchPort22 As String
Public SwitchPort23 As String
Public SwitchPort24 As String
End Class
End Namespace

<WebService(Description:="Status of Switch Interfaces ONLY ",
Namespace:="http://10.33.32.158/CoinsEngineV1")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Service
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function Get3750InterfaceInfo() As CiscoSwitch.SwitchInterfaces
Dim InterfaceStatus As New CiscoSwitch.SwitchInterfaces
Dim ArrayCounter As Integer = 0

Dim InterfaceInfo1(30) As String
InterfaceInfo1 = New String(30) {}
Dim InterfaceInfo2(30) As String
InterfaceInfo2 = New String(30) {}

Dim SNMPOutput As String = ""
Dim SNMPTargetDevice As String = "192.168.0.100"
Dim SNMPCommunityString As String = "public"
Dim WMILocator As Object = CreateObject("WBemScripting.SWBemLocator")
Dim WMIServices As Object = WMILocator.ConnectServer("",
"root\snmp\localhost")
Dim WMINamedValueSet As Object =
CreateObject("WBemScripting.SWBemNamedValueSet")
WMINamedValueSet.Add("AgentAddress", SNMPTargetDevice)
WMINamedValueSet.Add("AgentReadCommunityName", SNMPCommunityString)
'Dim colSystem = WMIServices.InstancesOf("SNMP_RFC1213_MIB_system",
, WMINamedValueSet)
Dim colSystem = WMIServices.InstancesOf("SNMP_RFC1213_MIB_ifTable",
, WMINamedValueSet)
Try
For Each objSystem As Object In colSystem
InterfaceStatus.SwitchPort.CStr(ArrayCounter) =
objSystem.IfOperStatus
ArrayCounter = ArrayCounter + 1
Next
Catch ex As Exception
SNMPOutput = "There is some kind of problem..."
End Try
Return InterfaceStatus

End Function
 
G

Guest

I tried that first-but, this is going into an Adobe Flash front end over a
web service. Based on my Flash code, each element in the XML file must have
a unique tag, such as:

InterfaceStatus.SwitchPort1 = "up"
InterfaceStatus.SwitchPort2 = "down"

Then the Flash front end can handle the variable values-as an array, it
simply says "object."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top