sachincool786 Posted December 27, 2015 Posted December 27, 2015 (edited) Public WithEvents oGroup1 As TagGroupPublic vidrios1, vidrios2, vidrios3, vidrios4, vidrios5, vidrios6, vidrios7, vidrios8, vidrios9 As StringPublic str_vidrios1, str_vidrios2, str_vidrios3, str_vidrios4, str_vidrios5, str_vidrios6, str_vidrios7, str_vidrios8, str_vidrios9 As StringPublic Sub Display_AnimationStart()Dim TagsInError1 As StringListOn Error Resume NextErr.ClearIf oGroup1 Is Nothing ThenSet oGroup1 = Application.CreateTagGroup(Me.AreaName, 500)If Err.Number ThenLogDiagnosticsMessage "Error creating TagGroup. Error: " _& Err.Description, ftDiagSeverityErrorExit SubEnd IfoGroup1.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 = TrueoGroup1.RefreshFromSource TagsInError1End IfEnd SubPrivate Sub oGroup1_Change(ByVal TagNames As IGOMStringList)On Error Resume NextDim oTag11, oTag21, oTag31, oTag41, oTag51, oTag61, oTag71 As TagDim oTag100 As TagDim str_bits1 As StringIf Not oGroup1 Is Nothing ThenSet 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.ClearEnd IftxtHorno.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" ThenoTag100.Value = 0End IfIf Mid(txtHorno, 1, 1) = "0" ThenoTag100.Value = 1End IfEnd SubI 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 StringDim i, j As IntegerDim Temp As DoubleTemp = Abs(CDbl(entrada))str_bits = "0000000000000000000000000000000"i = 0If Temp = 1 Thenstr_bits = "10000000000000000000000000000000"GoTo A:ElseIf Temp = 0 Thenstr_bits = "00000000000000000000000000000000"GoTo A:End IfFor i = 31 To 1 Step -1If Temp / 2 ^ i >= 1 Thenstr_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 IfNext iIf Temp = 1 Thenstr_bits = "1" & str_bitsElse:str_bits = "0" & str_bitsEnd IfA:End Function3) oTag100.Value = 1will update my PLC tag "[0]Glass[0]" high automatically or i have to write anything else??? Edited December 27, 2015 by sachincool786
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now