Announcement

Collapse
No announcement yet.

Split a string and place part as value in virtual device

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #31
    Here's a better way that will remove any HTML tags, not the specific one that was coded in the previous script:

    Code:
    Imports System.Text.RegularExpressions
    
    Sub Main(parm as object)
    	dim sVal as string = hs.deviceString(506)
    	dim splitVal() as string
    	splitVal = sVal.split("m")
    	splitVal(0) = StripTags(splitVal(0))
    	Dim Split0 As Double 
    	If Double.TryParse(splitVal(0),Split0) Then
    		hs.setdevicevaluebyref(6469, Split0, True)
    	Else
    		hs.writelog("Number Conversion","Conversion Failed")
    	End If
    End Sub
    
    Function StripTags(ByVal html As String) As String
    	' Remove HTML tags.
    	Return Regex.Replace(html, "<.*?>", "")
    End Function
    Greetings from Canada

    Cheers
    Al
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #32
      And again it worked.....

      Comment

      Working...
      X