Visual Basic & FactoryTalk View Studio SE

Rich Rich

Member
Join Date
Nov 2008
Location
UK
Posts
6
Good morning!

I've run into a stopping point with a Visual Basic task on a View Studio SE project and was wondering if anyone could point me in the right direction.

The process involves loading parameters from a text file into an array in a Control Logix PLC after a load button is presses.

The reverse then needs to be accomplished after the save button is pressed. The parameters need to be taken from the array and placed into a text file.

The first part has been sorted using a bit of VB script that utilises the command line in View Studio by sending a set instruction:
Code:
Application.ExecuteCommand ("set [CLX]Recipe.Line1 " & Chr(34) & TextLine & Chr(34))

I have tried to do the reverse but there doesn't appear to be a "read/get" command to do the opposite of set for the command interface in View Studio.

The RecipeSave command is close but just won't cut it in these circumstances since I can't display all of this data on a single screen o_O.

Does anyone know of way to accomplish this?
 
If this is in actual VBA, then don't mix and match VBA code and macro code. That is a path to insanity (which, using FTView SE, you are already well on).

Use VBA exclusively -
Basic - Global Declarations
Code:
Dim Tag_Name as String
Dim IO_Server as String
Dim My_Group as TagGroup
Dim HMITag as Tag
Dim ErrorTags as StringList
Build a list of tags you deal with often:
Code:
Public Sub Add_MyGroup()
   If My_Group is Nothing Then
      Set My_Group = Application.CreateTagGroup(Me.AreaName, 500)
   End If
   IO_Server = "{[My_PLC_Topic]"
   My_Group.Add IO_Server & "ASample_Tag}"
   My_Group.Add IO_Server & "ASample_StringTag}"

   My_Group.Active = True

End Sub
Then just read and write as needed:
Code:
Public Sub Read_StringTag()
Dim TagValue as String
   My_Group.RefreshFromSource ErrorTags ' refresh values
   TagValue = My_Group.Item(IO_Server & ASample_StringTag}").Value
End Sub

Public Sub Write_StringTag()
Dim Result as Boolean
   Tag_Name = IO_Server & "ASample_StringTag}"
   Set HMITag = MyGroup.Item(Tag_Name)
   HMITag.PendingWriteValue = "My New String For The Tag"
   Result = My_Group.WritePendingValues(ErrorTags)
End Sub

Add appropriate error checking.
 
Sorry for double posting but I can't find the edit button.

The solution worked brilliantly, I have suited the example to fit my application and it's now working a treat. Thanks!
 

Similar Topics

I'm just trying to load from a text file into a string. I don't get why this doesn't work. Function LoadFile(FileName As String) As String()...
Replies
0
Views
1,541
Hello, Im trying to learn how to use VBA with factorytalk view so i can later design displays using tags from PLCs and im having some trouble...
Replies
2
Views
3,784
I have a small application where i want to use a numeric input to change the tags for another numeric input i am referring to dynamically. I am...
Replies
6
Views
2,662
from visual basic I am trying to write to a variable in factorytalk called alarm, this variable is of binary type, should not be a problem but I...
Replies
4
Views
4,042
Dear experts, I am want to program RS view32 with help of Microsoft visual basic (visual basic editor). But how to start I don't know,please...
Replies
10
Views
2,368
Back
Top Bottom