Announcement

Collapse
No announcement yet.

VBscript to VB Net

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

    VBscript to VB Net

    Didn't need to use HS device(P99) for comparison. Just used a script variable and it now works.

    Let me first preface this by saying my scripting/programming skills are rudimentary at best. But I was able to cobble together a VBScript to control my pool.

    I have successfully converted all my VBScripts to VBNet except the pool control.

    I have this piece of code in the VBscript and it works
    PHP Code:
    'Leds
        if Left(strInString,3) = strLed then
          strBtn = Asc(Mid(strInString,4,1))
          strBtn2 = Asc(Mid(strInString,5,1))

             if hs.DeviceString("P99") <> strBtn&strBtn2 then
                    hs.SetDeviceString("P99"), strBtn&strBtn2

                Bin(strBtn)
                led1 = led
                      for i = 0 to 7
                     bitt = Mid(led1, i+1, 1)
                        if bitt <> "1" then
                      bitt = "0"
                    end if
                 hs.SetDeviceStatus "P"&i+1, 3-CInt(bitt)
              Next

                Bin(strBtn2)
                 led2 = led
                         for i = 0 to 7
                     bitt = Mid(led2, i+1, 1)
                        if bitt <> "1" then
                      bitt = "0"
                    end if
                 hs.SetDeviceStatus "P"&i+21, 3-CInt(bitt)
              Next
        
             End if    
         End if 
    I have this as VB Net and is doesn't
    PHP Code:
        'Leds
        If Left(strInString, 3) = strLed Then
            strBtn = Asc(Mid(strInString, 4, 1))
            strBtn2 = Asc(Mid(strInString, 5, 1))

            If hs.DeviceString("P99") <> (strBtn & strBtn2) Then
                hs.SetDeviceString("P99", (strBtn & strBtn2))
           
                Bin(strBtn)
                led1 = led
                
                For i = 0 To 7
                    bitt = Mid(led1, i + 1, 1)
                    If bitt <> "1" Then
                        bitt = "0"
                    End If
                    hs.SetDeviceStatus("P" & i + 1, 3 - CInt(bitt))
                Next

                Bin(strBtn2)
                led2 = led

                For i = 0 To 7
                    bitt = Mid(led2, i + 1, 1)
                    If bitt <> "1" Then
                        bitt = "0"
                    End If
                    hs.SetDeviceStatus("P" & i + 21, 3 - CInt(bitt))
                Next
                
            End If
        End If 
    I don't get any errors in the HS log. Anyone have an idea what I have wrong in the VBNet version?
    Last edited by jbbtex; March 16, 2012, 08:46 AM. Reason: Fixed
Working...
X