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. simple question

simple question

Scheduled Pinned Locked Moved Visual Basic
question
6 Posts 3 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.
  • N Offline
    N Offline
    ns
    wrote on last edited by
    #1

    I have a string which should have either the substring ID in it, or the substring ID_NUMBER (it looks like

    s = abc;adf;ID;ghj;ID_NUMBER;jjj 
    

    if at least one of these values is there, then I want to continue. But if neither is there, I want to exit the function. I've done:

     If Not InStr(s, "ID") Or Not InStr(s, "ID_NUMBER") Then
                
                    MakeDB = -1
                    
                    Exit Function
                    
                End If
    

    but I think I'm wrong. :confused::confused: Thanks, ns

    P 1 Reply Last reply
    0
    • N ns

      I have a string which should have either the substring ID in it, or the substring ID_NUMBER (it looks like

      s = abc;adf;ID;ghj;ID_NUMBER;jjj 
      

      if at least one of these values is there, then I want to continue. But if neither is there, I want to exit the function. I've done:

       If Not InStr(s, "ID") Or Not InStr(s, "ID_NUMBER") Then
                  
                      MakeDB = -1
                      
                      Exit Function
                      
                  End If
      

      but I think I'm wrong. :confused::confused: Thanks, ns

      P Offline
      P Offline
      Paul Riley
      wrote on last edited by
      #2

      ns wrote: If Not InStr(s, "ID") Or Not InStr(s, "ID_NUMBER") Then If it doesn't find "ID" then it isn't going to find "ID_NUMBER". I think that Or is wrong anyway but it's not even necessary, If Not InStr(s, "ID") Then would suffice. As a side note, I don't personally trust VBs handling of intesgers in boolean expressions. I'd be tempted to add a > 0 to be sure. Paul

      N N 2 Replies Last reply
      0
      • P Paul Riley

        ns wrote: If Not InStr(s, "ID") Or Not InStr(s, "ID_NUMBER") Then If it doesn't find "ID" then it isn't going to find "ID_NUMBER". I think that Or is wrong anyway but it's not even necessary, If Not InStr(s, "ID") Then would suffice. As a side note, I don't personally trust VBs handling of intesgers in boolean expressions. I'd be tempted to add a > 0 to be sure. Paul

        N Offline
        N Offline
        ns
        wrote on last edited by
        #3

        Thanks very much. I didnt see your point at first then it dawned on me ....duh :) Appreciate your help ! Thanks, ns

        1 Reply Last reply
        0
        • P Paul Riley

          ns wrote: If Not InStr(s, "ID") Or Not InStr(s, "ID_NUMBER") Then If it doesn't find "ID" then it isn't going to find "ID_NUMBER". I think that Or is wrong anyway but it's not even necessary, If Not InStr(s, "ID") Then would suffice. As a side note, I don't personally trust VBs handling of intesgers in boolean expressions. I'd be tempted to add a > 0 to be sure. Paul

          N Offline
          N Offline
          Nick Parker
          wrote on last edited by
          #4

          Paul Riley wrote: As a side note, I don't personally trust VBs handling of intesgers in boolean expressions. I'd be tempted to add a > 0 to be sure. VB will *handle* them correctly, however sometimes it is best to litterally check the value of what is being returned. I agree. :) Nick Parker
          **The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown


          **

          P 1 Reply Last reply
          0
          • N Nick Parker

            Paul Riley wrote: As a side note, I don't personally trust VBs handling of intesgers in boolean expressions. I'd be tempted to add a > 0 to be sure. VB will *handle* them correctly, however sometimes it is best to litterally check the value of what is being returned. I agree. :) Nick Parker
            **The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown


            **

            P Offline
            P Offline
            Paul Riley
            wrote on last edited by
            #5

            Nick Parker wrote: VB will *handle* them correctly, however sometimes it is best to litterally check the value of what is being returned. I agree. I guess this is what comes of using many different languages that all act differently, you get to the point where you don't trust any of them and end up being as specific as possible at all times. C(++) has left me using parentheses absolutely everywhere :laugh:. This is all a good thing, in my humblest opinion. More precise coding is more readable coding. Contrary to popular opinion, it is possible to code VB well ;) Paul

            N 1 Reply Last reply
            0
            • P Paul Riley

              Nick Parker wrote: VB will *handle* them correctly, however sometimes it is best to litterally check the value of what is being returned. I agree. I guess this is what comes of using many different languages that all act differently, you get to the point where you don't trust any of them and end up being as specific as possible at all times. C(++) has left me using parentheses absolutely everywhere :laugh:. This is all a good thing, in my humblest opinion. More precise coding is more readable coding. Contrary to popular opinion, it is possible to code VB well ;) Paul

              N Offline
              N Offline
              Nick Parker
              wrote on last edited by
              #6

              Paul Riley wrote: Contrary to popular opinion, it is possible to code VB well Fully agreed, I suppose we should watch how we talk about VB here in C++ country though. :laugh: :cool: Nick Parker
              **The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown


              **

              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