Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. InStr & Mid$

InStr & Mid$

Scheduled Pinned Locked Moved Visual Basic
question
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dec82
    wrote on last edited by
    #1

    hi, i have these code with temperature="TEMP(C) 37.0:\r\n" X = InStr(1, temperature, ")") temperature = Mid$(temperature, X + 2, 4) After the code is excuted , will i have temperature = 37.0 Cause i execute and the value of temperature is not stable ? Thanks

    A 1 Reply Last reply
    0
    • D dec82

      hi, i have these code with temperature="TEMP(C) 37.0:\r\n" X = InStr(1, temperature, ")") temperature = Mid$(temperature, X + 2, 4) After the code is excuted , will i have temperature = 37.0 Cause i execute and the value of temperature is not stable ? Thanks

      A Offline
      A Offline
      Alan N
      wrote on last edited by
      #2

      Hi, Your code will extract the substring from the position given. What do you mean by the value of temperature is not stable? Alan.

      D 1 Reply Last reply
      0
      • A Alan N

        Hi, Your code will extract the substring from the position given. What do you mean by the value of temperature is not stable? Alan.

        D Offline
        D Offline
        dec82
        wrote on last edited by
        #3

        Actually my code is used to get the temperature of the devices . Normally the values in the range 35-39 . But sometimes i got 6 or 7... which are surely wrong ? Thanks

        A 1 Reply Last reply
        0
        • D dec82

          Actually my code is used to get the temperature of the devices . Normally the values in the range 35-39 . But sometimes i got 6 or 7... which are surely wrong ? Thanks

          A Offline
          A Offline
          Alan N
          wrote on last edited by
          #4

          Well that would tend to indicate that the device is returning the wrong information. Log all data to a text file and then take a look at the file to see if there is any pattern to the bad values. Your options are to fix the device, or if that is not possible to write code to ignore the bad values. Until you know a lot more about the data that is coming from the device you can't begin to parse it reliably. Alan.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups