Click here to Skip to main content
15,905,912 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionAn error occurred while performing the drop: Illegal characters in path Pin
DirtBagger31-Mar-09 11:07
DirtBagger31-Mar-09 11:07 
QuestionDynamic PropertyGrid with CheckListBox Pin
jackgreat31-Mar-09 7:05
jackgreat31-Mar-09 7:05 
QuestionSet Wallpaper Pin
Pasan14831-Mar-09 5:23
Pasan14831-Mar-09 5:23 
AnswerRe: Set Wallpaper Pin
0x3c031-Mar-09 6:39
0x3c031-Mar-09 6:39 
QuestionOn Error GoTo in VBScript Pin
ATM_Guy31-Mar-09 4:59
ATM_Guy31-Mar-09 4:59 
AnswerRe: On Error GoTo in VBScript Pin
riced31-Mar-09 5:26
riced31-Mar-09 5:26 
GeneralRe: On Error GoTo in VBScript Pin
Uros Calakovic31-Mar-09 6:57
Uros Calakovic31-Mar-09 6:57 
QuestionProblem with movetoroot from the opc da automation wrapper Pin
dadio2531-Mar-09 3:53
dadio2531-Mar-09 3:53 
Hello i don't know if this is the correct forum since i'm using vba excel.

My problem consists when trying too program my own opc client. I use a kepware simulation server too test my client.

In my program i use a treeview too show the layout of the server. If I click on the treeview it should show the items in that particular group. I can do that two times when i try too do that the third time i get an error that it can't find that particular item, but since it's in the treeview i know it excists.

this is how i connect too the server:

Set OPCMyserver = New OPCServer
        OPCMyserver.Connect Selectedserver.Caption           'We try to connect to OPC server
        Selectedname = Selectedserver.Caption
        Set OPCMygroups = OPCMyserver.OPCGroups         'We load the OPC Groups
 
        OPCMygroups.DefaultGroupDeadband = 0
        OPCMygroups.DefaultGroupIsActive = True
        OPCMygroups.DefaultGroupUpdateRate = 100
              

        
        Set OPCMygroup = OPCMygroups.Add("Group_1")     'We add a group, the name is not important
                       
        Set OPCMyitems = OPCMygroup.OPCItems            'We load the OPC Items located in the OPC Group
  
        Set OPCMyBrowser = OPCMyserver.CreateBrowser    'For the navigation in the OPC server
        OPCMyBrowser.Showbranches


This is what shouls happen if you click on a node in the treeview

Private Sub OPCtree_NodeClick(ByVal SelectedNode As Node)
Dim itemnaam As String
Dim itemteller As Long
Dim anItem As OPCItem

Itemlist.ListItems.Clear
OPCMyBrowser.MoveToRoot
Set SelectedNode = OPCtree.SelectedItem
browseposition SelectedNode.Key

OPCMyBrowser.ShowLeafs

itemteller = OPCMyBrowser.count
    
    For Each vName In OPCMyBrowser
        itemnaam = "" + OPCMyBrowser.GetItemID(vName)
        Itemlist.ListItems.Add , , itemnaam
    Next vName
    Dim I As Integer
         
        
    For I = 1 To itemteller             'We add all the OPC Items of the ListView to the Collection of OPC Items
            
         OPCItemIDs(1) = Itemlist.ListItems(I)
         OPCMyitems.AddItems 1, OPCItemIDs, ClientHandles, ItemServerHandles, Errors
    Next I
   
    OPCMygroup.IsActive = Not OPCMygroup.IsActive           'Necessary to refresh data
    OPCMygroup.IsSubscribed = Not OPCMygroup.IsSubscribed   'Necessary to refresh data
    OPCMygroup.UpdateRate = Val(100)            'Use the refresh time

    For I = 1 To Itemlist.ListItems.count                          'For all the items in the ListView
   
    For Each anItem In OPCMygroup.OPCItems                          'For all OPC Items
        
        anItem.Read OPCDevice                                       'Read the item, and the Item Id is the same than the current name in the ListView...
        If anItem.ItemID = Itemlist.ListItems(I) Then
            Itemlist.ListItems(I).SubItems(1) = anItem.Value      '...get the Item Value...
            Itemlist.ListItems(I).SubItems(2) = anItem.TimeStamp  '...get the Item TimeStamp...
            Itemlist.ListItems(I).SubItems(3) = anItem.Quality    '...get the Item Quality
            Exit For
        End If
    Next anItem
    
  Next I
    Set anItem = Nothing
    OPCMyBrowser.MoveToRoot
        
End Sub

And this is how i browse for the correct position
Private Sub browseposition(ByVal Positie As String)
    
    Dim I As Integer
    Dim NormalPosition As String
    Dim comparestring As String
    Dim teller As Integer
    Dim bfound As Boolean

    OPCMyBrowser.MoveToRoot
    NormalPosition = Positie

         OPCMyBrowser.Showbranches
         For Each vName In OPCMyBrowser
         comparestring = "" + vName
         teller = Len(comparestring)
        If Left(NormalPosition, Len(comparestring)) = comparestring Then: bfound = True: Exit For
         Next vName
If bfound Then
           Do While (Len(NormalPosition)) > 0
                OPCMyBrowser.MoveDown (comparestring)
                comparestring = "" + Mid(NormalPosition, (Len(comparestring) + 2))
                NormalPosition = comparestring
        Loop
Else
    
    MsgBox "No Match was Found for " & NormalPosition, vbInformation, "Match Failure"

End If
                
End Sub


I know it's rather a lot of code I added, but I didn't know what I should add and I can't find were it goes wrong. I only know that OPCMyBrowser.Movetoroot doesn't do it's job the third time.

I hope someone knows or sees what i'm doing wrong is.

greetings dadio25
AnswerRe: Problem with movetoroot from the opc da automation wrapper Pin
dadio251-Apr-09 20:47
dadio251-Apr-09 20:47 
GeneralDisplay External Window in vb Form Pin
Samir Ibrahim31-Mar-09 2:48
Samir Ibrahim31-Mar-09 2:48 
GeneralRe: Display External Window in vb Form Pin
Dave Kreskowiak31-Mar-09 3:23
mveDave Kreskowiak31-Mar-09 3:23 
GeneralRe: Display External Window in vb Form Pin
Samir Ibrahim31-Mar-09 4:05
Samir Ibrahim31-Mar-09 4:05 
GeneralRe: Display External Window in vb Form Pin
0x3c031-Mar-09 6:55
0x3c031-Mar-09 6:55 
GeneralRe: Display External Window in vb Form Pin
Dave Kreskowiak31-Mar-09 7:26
mveDave Kreskowiak31-Mar-09 7:26 
GeneralRe: Display External Window in vb Form Pin
Samir Ibrahim1-Apr-09 5:07
Samir Ibrahim1-Apr-09 5:07 
QuestionFind Window Pin
Prasadsm31-Mar-09 1:38
Prasadsm31-Mar-09 1:38 
AnswerRe: Find Window Pin
Eddy Vluggen31-Mar-09 1:56
professionalEddy Vluggen31-Mar-09 1:56 
GeneralRe: Find Window Pin
Prasadsm31-Mar-09 2:01
Prasadsm31-Mar-09 2:01 
GeneralRe: Find Window Pin
Eddy Vluggen31-Mar-09 2:35
professionalEddy Vluggen31-Mar-09 2:35 
QuestionDelete Lines in Text File Pin
vijay248230-Mar-09 23:37
vijay248230-Mar-09 23:37 
AnswerRe: Delete Lines in Text File Pin
Prasadsm31-Mar-09 2:15
Prasadsm31-Mar-09 2:15 
AnswerRe: Delete Lines in Text File Pin
riced31-Mar-09 5:21
riced31-Mar-09 5:21 
QuestionI created a superscript in a rich text box but neeed to convert the same to caret sign in a text box Pin
gautamrajsaxena30-Mar-09 22:18
gautamrajsaxena30-Mar-09 22:18 
Questionplz help me to jump the return code to pass program check Pin
wgarnett30-Mar-09 21:37
wgarnett30-Mar-09 21:37 
AnswerRe: plz help me to jump the return code to pass program check Pin
Eddy Vluggen30-Mar-09 22:58
professionalEddy Vluggen30-Mar-09 22:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.