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. Need help on which function/method to use [SOLVED]

Need help on which function/method to use [SOLVED]

Scheduled Pinned Locked Moved Visual Basic
helpdatabasequestion
6 Posts 4 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.
  • V Offline
    V Offline
    vijay2482
    wrote on last edited by
    #1

    Hi all, I'm working on a application which searches for '_FLEX' or '_FLEX_' or '_CABLE' or _'FERME' in a text file. If found do some action. I use the below code to set the index to search for the above words. Issue: There is a line in the text file in the name fields with '_FLEX1'. When this word is found, it does the actions that need to be done for lpFlex or lpFlex_ found. I have used name.IndexOf for '_FLEX' and '_FLEX_' but when found'_FLEX1', it has performed the actionsof lpFlex or lpFlex_. I dont want any action to be done when something other than lpFlex or lpCable or lpFeme or lpFlex_ found. I think its because I use name.IndexOf(). Is there some other function/method to search for the specific word in a field/line? Where am I going wrong? Any help and suggestion please. Thanks in Advance.

    modified on Monday, October 26, 2009 11:13 AM

    S H 2 Replies Last reply
    0
    • V vijay2482

      Hi all, I'm working on a application which searches for '_FLEX' or '_FLEX_' or '_CABLE' or _'FERME' in a text file. If found do some action. I use the below code to set the index to search for the above words. Issue: There is a line in the text file in the name fields with '_FLEX1'. When this word is found, it does the actions that need to be done for lpFlex or lpFlex_ found. I have used name.IndexOf for '_FLEX' and '_FLEX_' but when found'_FLEX1', it has performed the actionsof lpFlex or lpFlex_. I dont want any action to be done when something other than lpFlex or lpCable or lpFeme or lpFlex_ found. I think its because I use name.IndexOf(). Is there some other function/method to search for the specific word in a field/line? Where am I going wrong? Any help and suggestion please. Thanks in Advance.

      modified on Monday, October 26, 2009 11:13 AM

      S Offline
      S Offline
      sri_0099
      wrote on last edited by
      #2

      Vijay, use contains method like.. If name.contains("") 'your code Hope it helps

      V L 2 Replies Last reply
      0
      • V vijay2482

        Hi all, I'm working on a application which searches for '_FLEX' or '_FLEX_' or '_CABLE' or _'FERME' in a text file. If found do some action. I use the below code to set the index to search for the above words. Issue: There is a line in the text file in the name fields with '_FLEX1'. When this word is found, it does the actions that need to be done for lpFlex or lpFlex_ found. I have used name.IndexOf for '_FLEX' and '_FLEX_' but when found'_FLEX1', it has performed the actionsof lpFlex or lpFlex_. I dont want any action to be done when something other than lpFlex or lpCable or lpFeme or lpFlex_ found. I think its because I use name.IndexOf(). Is there some other function/method to search for the specific word in a field/line? Where am I going wrong? Any help and suggestion please. Thanks in Advance.

        modified on Monday, October 26, 2009 11:13 AM

        H Offline
        H Offline
        Henry Minute
        wrote on last edited by
        #3

        If I understand your question correctly, you only want the action to happen if an exact match is found for one of your trigger words. This might be very difficult, although it partly depends on what character 'should' follow them. For example, if they should always be followed by a space, then test for "_FLEX ", "_CABLE " etc. If "_FLEX1", is guaranteed to be the only 'problem' then a test like:

        If sampleText.SubString(resultOfIndexOf, 6) = "_FLEX1" THEN Return 'or whatever will ignore that entry

        If they can be followed by anything then it would be extremely difficult. It may be possible by using Regular Expressions but I do not have sufficient skills in that area to say for sure. If after a couple more hours no-one has offered a solution I suggest that you post a new question with a title like "Regular Expression problem", that will usually attract the Expressionistas. If you do that, please be sure to mention that you asked earlier but got no luck but someone suggested RE might do the trick. Good Luck! :)

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        V 1 Reply Last reply
        0
        • S sri_0099

          Vijay, use contains method like.. If name.contains("") 'your code Hope it helps

          V Offline
          V Offline
          vijay2482
          wrote on last edited by
          #4

          Thanks for your reply and suggestion.

          1 Reply Last reply
          0
          • H Henry Minute

            If I understand your question correctly, you only want the action to happen if an exact match is found for one of your trigger words. This might be very difficult, although it partly depends on what character 'should' follow them. For example, if they should always be followed by a space, then test for "_FLEX ", "_CABLE " etc. If "_FLEX1", is guaranteed to be the only 'problem' then a test like:

            If sampleText.SubString(resultOfIndexOf, 6) = "_FLEX1" THEN Return 'or whatever will ignore that entry

            If they can be followed by anything then it would be extremely difficult. It may be possible by using Regular Expressions but I do not have sufficient skills in that area to say for sure. If after a couple more hours no-one has offered a solution I suggest that you post a new question with a title like "Regular Expression problem", that will usually attract the Expressionistas. If you do that, please be sure to mention that you asked earlier but got no luck but someone suggested RE might do the trick. Good Luck! :)

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

            V Offline
            V Offline
            vijay2482
            wrote on last edited by
            #5

            Thanks for your reply. I have changed tthe below from:

            lpFlex = name.IndexOf("_FLEX")
            lpCable = name.IndexOf("_CABLE")
            lpFerme = name.IndexOf("_FERME")
            lpFlex_ = name.IndexOf("_FLEX_")

            to:

            lpFlex = name.IndexOf("_FLEX.")
            lpCable = name.IndexOf("_CABLE_")
            lpFerme = name.IndexOf("_FERME_")
            lpFlex_ = name.IndexOf("_FLEX_")

            which solved my purpose. when there is a _FLEX. or _FLEX_ found, the application does some action when something else other than these found, it will be written as such. The written line will be processed by another function in my application and will be removed from the text file. Anyways thanks for this suggestion. Will make use of it some where else.

            1 Reply Last reply
            0
            • S sri_0099

              Vijay, use contains method like.. If name.contains("") 'your code Hope it helps

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              string.Contains will give you the same problems. Use regular expression instead.

              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