1

I have dded a VisM control into vb.net via adding a reference to VisM.ocx and adding it in my toolbox as an activeX control.

I added the following code in a button:

Try
    'open the connection
        AxVisM1.Connect("CN_IPTCP:127.0.0.1[1972]")
    'set namespace to livedata (for formal namespaces, use the @ symbol)
        AxVisM1.NameSpace = "LIVEDATA"


    'do stuff.
    MsgBox("Cache is now active")

    'close the connection
    AxVisM1.DeleteConnection()

Catch ex As Exception
    'close the connection
    AxVisM1.DeleteConnection()

    MsgBox(ex.ToString)

End Try

From here, I need to output variables from GLOBALs named ^BACKTR("INDX","COMPANY",

how do I output all/some variables from this GLOBALs into a list, a datatable, or a single variable even? All I need is to access it in VB.net and from there I can work with the said GLOBALs for my project. I will accept even if the output is raw (not in columns or anything ie: ^BACKTR("INDX","COMPANY",1,63572,9792) = "" as from it I can already use the data in my application

Malcolm Salvador
  • 1,476
  • 2
  • 21
  • 40

1 Answers1

3

Something like this, code below reads data from ^BACKTR("DATA","STATISTICS") and puts it to ListVew. It executes COS code for getting data with AxVisM1.Execute. Look at $order function, and about P0 and VALUE in vism in documentation

        Dim cnt As Integer = 0
        ListView1.Items.Clear()
        ListView1.Columns.Clear()
        ListView1.Columns.Add("#")
        ListView1.Columns.Add("ID")
        For i = 1 To 25
            ListView1.Columns.Add("Prop" + i.ToString)
        Next

        AxVisM1.P0 = ""
        While True
            AxVisM1.Execute("set P0=$order(^BACKTR(""DATA"",""STATISTICS"",P0),1,VALUE)")
            If (AxVisM1.P0 = "") Then
                Exit While
            End If
            cnt = cnt + 1
            If (cnt > 100) Then
                Exit While
            End If

            Dim data() As String = Split(AxVisM1.VALUE, Chr(1).ToString)
            Dim line As ListViewItem = New ListViewItem(cnt)
            line.SubItems.Add(AxVisM1.P0.ToString)
            line.SubItems.AddRange(data)
            ListView1.Items.Add(line)

        End While
DAiMor
  • 3,185
  • 16
  • 24