Announcement

Collapse
No announcement yet.

Instr function

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

    Instr function

    I receive weather alerts info from a plugin. The titles associated with the alert are not very descriptive. I am trying to grab the title form the first part of the alert string.
    Code:
    FirstAlert =...Dense fog advisory remains in effect until 10 am EST Monday... Weather... widespread fog, with areas of dense fog, will persist into the overnight hours. Northeast winds around 5 mph. Impacts... locations impacted by dense fog will have surface visibilities of one quarter of a mile or less with localized visibilities near zero. However, highly variable visibilities can be expected. Precautionary/preparedness actions... motorists are urged to use caution and account for variable driving conditions by slowing down and allowing extra time.
    I have tried Title = Left(FirstAlert,InStr(FirstAlert,"... Weather")), but it does it does not work. It return a blank title.

    What am I doing incorrectly & or is there a better way to accomplish this ?
    Larry

    #2
    Looks correct, but I would use the substring function going forward (https://msdn.microsoft.com/en-us/lib...code-snippet-2) for vb.net, or potentially regular expressions. You may have some HTML or other hidden characters embedded in the string.

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

    Comment


      #3
      Originally posted by lpcalcaterra View Post
      I receive weather alerts info from a plugin. The titles associated with the alert are not very descriptive. I am trying to grab the title form the first part of the alert string.
      Code:
      FirstAlert =...Dense fog advisory remains in effect until 10 am EST Monday... Weather... widespread fog, with areas of dense fog, will persist into the overnight hours. Northeast winds around 5 mph. Impacts... locations impacted by dense fog will have surface visibilities of one quarter of a mile or less with localized visibilities near zero. However, highly variable visibilities can be expected. Precautionary/preparedness actions... motorists are urged to use caution and account for variable driving conditions by slowing down and allowing extra time.
      I have tried Title = Left(FirstAlert,InStr(FirstAlert,"... Weather")), but it does it does not work. It return a blank title.

      What am I doing incorrectly & or is there a better way to accomplish this ?
      Is there a space between the ... and Weather?
      💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

      Comment


        #4
        thanks guys. I modified the script to use substring.
        Larry

        Comment

        Working...
        X