Statservice SDK - Problem using converting sample c# code to vb.net

EDIT - Just realised this should probably be in the Developer Forum, so please feel free to move! Sorry!!

Hi all,

I’m using vb.net to code a stats retrieval app. I’m having a problem with casting one of the types used for creating the statistics object for retreiving some stats. I have added 2 web references to the project:

[b]GIS_SessionService

GIS_StatService[/b]

I can login and get a session ID fine. The issue is with code to build the stat. I’ve copied this code from the c# example in the 7.1 stats sdk developers guide, and tried to modify it to work in vb.net.

In this code within my sub:

        Dim statistic As New GIS_StatService.statistic()
        statistic.statisticId = "statref1"

        Dim objectIdType As New GIS_StatService.objectIdType()
        System.Console.WriteLine("Statistic needed for Agent1961")

        objectIdType.id = "icstest02"

        objectIdType.tenantName = "Resources"

        statistic.objectId = objectIdType
        'Then build metric data.
        Dim metric As New GIS_StatService.metric()
        Dim statisticType As New GIS_StatService.statisticType()

        'objectType[] ot = new objectType[]{objectType.Agent};

        Dim ot As New GIS_StatService.objectType()
        statisticType.objectType = ot

I get this error on the last line, with ot highlighted:

Value of type ‘GIS_Connect.GIS_StatService.objectType’ cannot be converted to ‘1-dimensional array of GIS_Connect.GIS_StatService.objectType’

Any help is greatly appreciated, I must be casting the object ‘ot’ incorrectly but I’m not sure how to cast it correctly.

Thanks,

Mick

Hi Mick,

The value of “statisticType.objectType” has to be 1-dimensional array of instances of the class “objectType”. Below is code sniped but I haven’t been able to test as don’t have access to GIS now.

Dim ot() As new GIS_StatService.objectType={objectType.Agent}
statisticType.objectType = ot

R.

Hi Rene,
Thanks for the response. I’ve put your code line in there, but now I get the following errors:

={objectType.Agent} 

is underlined with the message “expected end of statement”

ot

is underlined with the message “Name ‘ot’ is not declared”

Hope you can help further! :slight_smile:

Thanks,
Hynsey

2 Likes

Hi Rene,
I modified the code to this:

Dim ot() As GIS_StatService.objectType = {GIS_StatService.objectType.Agent}
        statisticType.objectType = ot

and it works now! Thanks for the help!! :slight_smile:

Cheers,
hynsey