Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8724991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:56:22+00:00 2026-06-13T07:56:22+00:00

Ok, the following code I’m reading in a text file and searching for a

  • 0

Ok, the following code I’m reading in a text file and searching for a specific string in a line. If the string is found, I don’t want to do anything and if it’s not found, I want to do something else. Right now I have a msgbox for each condition.

The problem I have, is when string is not found, it’s not triggering the msgbox. The other msgbox triggers when the string is found though.

Any ideas?

    Dim logfile() As String = System.IO.File.ReadAllLines("C:\Temp\Transfer_Log.txt")
    Dim searchstring As String = "Test_" + DateTimePicker2.Value.ToString("yyyyMMdd") + ".csv"

    For Each line As String In Filter(logfile, searchstring)
        If line.Contains("Test_" + DateTimePicker2.Value.ToString("yyyyMMdd") + ".csv") Then
            MsgBox("Do Nothing") 'THIS WORKS
        Else
            MsgBox("Append") 'THIS DOES NOT WORK
        End If
    Next
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:56:22+00:00Added an answer on June 13, 2026 at 7:56 am

    If I’m interpreting your code correcty, Filter is a filtering funciton that is returing all lines that match the text "Test_" + DateTimePicker2.Value.ToString("yyyyMMdd") + ".csv". Then you are looping through each line and again comparing it to see if it matches "Test_" + DateTimePicker2.Value.ToString("yyyyMMdd") + ".csv". So your second message box will never be called, ever. I would suggest this,

     IF Filter(logFile, searchstring).Count > 0 Then 
          MsgBox("Do Nothing")
     Else
          MsgBox("Append")
     EndIf
    

    According to the question, you want to know if the string exists in the file or not, and this will tell you if it does or not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following code climate analysis, I found that my controllers are not DRY as it
Following code found that output results is not the order, not from small to
Following code transfer file successfully, but does not print in lable that it has
Following code gets executed whenever I want to persist any entity. Things seems to
Following code I can use for storing the value of UILabel into a string.
Following code has to be used in the main-function, but I don't know how
Following code is saved as html file: <?php $IP = 4; ?> <textarea name=comments>$IP</textarea>
following code works perfectly on FF and Chrome but not in IE8. $(window).keyup(function(e) {
Following code is an example of text placed into a textarea from a database.
Following code work for visualizing a molecule on a JPanel except it does not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.