Sign in to follow this  
Followers 0
sachincool786

VBA code problem used for FT View SE v8.0 ...need ur help to find the bug

1 post in this topic

#1 ·  Posted (edited)

Public WithEvents oGroup1 As TagGroup
Public vidrios1, vidrios2, vidrios3, vidrios4, vidrios5, vidrios6, vidrios7, vidrios8, vidrios9 As String
Public str_vidrios1, str_vidrios2, str_vidrios3, str_vidrios4, str_vidrios5, str_vidrios6, str_vidrios7, str_vidrios8, str_vidrios9 As String


Public Sub Display_AnimationStart()
Dim TagsInError1 As StringList
On Error Resume Next
Err.Clear
If oGroup1 Is Nothing Then
Set oGroup1 = Application.CreateTagGroup(Me.AreaName, 500)
If Err.Number Then
LogDiagnosticsMessage "Error creating TagGroup. Error: " _
& Err.Description, ftDiagSeverityError
Exit Sub
End If
oGroup1.Add "[0]comm_furnace_glasses[0]"
oGroup1.Add "[0]comm_furnace_glasses[1]"
oGroup1.Add "[0]comm_furnace_glasses[2]"
oGroup1.Add "[0]comm_furnace_glasses[3]"
oGroup1.Add "[0]comm_furnace_glasses[4]"
oGroup1.Add "[0]comm_furnace_glasses[5]"
oGroup1.Add "[0]comm_furnace_glasses[6]"
oGroup1.Add "[0]Glass[0]"
oGroup1.Active = True
oGroup1.RefreshFromSource TagsInError1
End If

End Sub


Private Sub oGroup1_Change(ByVal TagNames As IGOMStringList)
On Error Resume Next
Dim oTag11, oTag21, oTag31, oTag41, oTag51, oTag61, oTag71 As Tag
Dim oTag100 As Tag

Dim str_bits1 As String

If Not oGroup1 Is Nothing Then
Set oTag11 = oGroup1.Item("[0]comm_furnace_glasses[0]")
Set oTag21 = oGroup1.Item("[0]comm_furnace_glasses[1]")
Set oTag31 = oGroup1.Item("[0]comm_furnace_glasses[2]")
Set oTag41 = oGroup1.Item("[0]comm_furnace_glasses[3]")
Set oTag51 = oGroup1.Item("[0]comm_furnace_glasses[4]")
Set oTag61 = oGroup1.Item("[0]comm_furnace_glasses[5]")
Set oTag71 = oGroup1.Item("[0]comm_furnace_glasses[6]")
Set oTag100 = oGroup1.Item("[0]Glass[0]")

m_vidrios.str_bits (str_bits1)

str_vidrios1 = str_bits1(CStr(oTag11))
str_vidrios2 = str_bits1(CStr(oTag21))
str_vidrios3 = str_bits1(CStr(oTag31))
str_vidrios4 = str_bits1(CStr(oTag41))
str_vidrios5 = str_bits1(CStr(oTag51))
str_vidrios6 = str_bits1(CStr(oTag61))
str_vidrios7 = str_bits1(CStr(oTag71))
Err.Clear
End If
txtHorno.Value = "Mid(str_vidrios1, 1, 31) & Mid(str_vidrios2, 1, 31) & Mid(str_vidrios3, 1, 31) & Mid(str_vidrios4, 1, 31) & Mid(str_vidrios5, 1, 31) & Mid(str_vidrios6, 1, 31) & Mid(str_vidrios7, 1, 31)"

If Mid(txtHorno, 1, 1) = "1" Then

oTag100.Value = 0

End If

If Mid(txtHorno, 1, 1) = "0" Then

oTag100.Value = 1

End If
End Sub




I have some doubts , please help debugging it :

1) txtHorno is a name of string display object (which is VBA controlled) :

txtHorno.Value = "Mid(str_vidrios1, 1, 31) & Mid(str_vidrios2, 1, 31) & Mid(str_vidrios3, 1, 31) & Mid(str_vidrios4, 1, 31) & Mid(str_vidrios5, 1, 31) & Mid(str_vidrios6, 1, 31) & Mid(str_vidrios7, 1, 31)"

is it right???
should i write "" because this is returning a string???
should i write "txtHorno.Value =" or just "txtHorno ="
if not please tell me the correct way to write it, actually txtHorno is a string in which i want to move the above(function returned) value.


2)m_vidrios is my module name in which i have defined a public function so that i can use it in my form :

m_vidrios.str_bits (str_bits1)

Is it a right way to call it???

The code of module named "m_vidrios" is :

Function str_bits(entrada As String) As String

Dim i, j As Integer
Dim Temp As Double

Temp = Abs(CDbl(entrada))

str_bits = "0000000000000000000000000000000"

i = 0

If Temp = 1 Then

str_bits = "10000000000000000000000000000000"

GoTo A:

ElseIf Temp = 0 Then

str_bits = "00000000000000000000000000000000"

GoTo A:

End If

For i = 31 To 1 Step -1

If Temp / 2 ^ i >= 1 Then

str_bits = Mid(str_bits, 2, i - 1) & "1" & Mid(str_bits, i + 1, Len(str_bits) - i)

Temp = Temp - (2 ^ i)

Else:

str_bits = Mid(str_bits, 2, i - 1) & "0" & Mid(str_bits, i + 1, Len(str_bits) - i)

End If

Next i

If Temp = 1 Then

str_bits = "1" & str_bits

Else:
str_bits = "0" & str_bits

End If





A:

End Function






3) oTag100.Value = 1

will update my PLC tag "[0]Glass[0]" high automatically or i have to write anything else???

Edited by sachincool786

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0