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 8145519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:41:16+00:00 2026-06-06T13:41:16+00:00

I have a userform in 2008 vb express edition. A part number is created

  • 0

I have a userform in 2008 vb express edition. A part number is created from user input via a concat string. I want to then check if a certain portion of the part number exists in the existing file names in a directory. Below is a more detailed explanation.

This is my code for creating a part number from the user input on the form.

L_PartNo.Text = String.Concat(CB_Type.Text, CB_Face.Text, "(", T_Width.Text, "x", T_Height.Text, ")", mount, T_Qty.Text, weep, serv)

I then have the following code to tell the user if the configuration (part no) they just created exists

L_Found.Visible = True
If File.Exists("Z:\Cut Sheets\TCS Products\BLANK OUT SIGN\" & (L_PartNo.Text) & ".pdf") Then
        L_Found.Text = "This configuration exists"
      Else
        L_Found.Text = "This configuration does NOT exist"
      End If

This is where I need help. The part no will look like this BX002(30×30)A1SS I want to compare 002(30×30) (just this part of the file name) to all the files in one directory. I want a yes or no answer to the existance and not a list of all matching files. The code below is everything I’ve tried, not all at the same time.

Dim b As Boolean
b = L_PartNo.Text.Contains(NewFace)

Dim NewFace As String = String.Concat(CB_Face.Text, "(", T_Width.Text, "x", T_Height.Text, ")")
Dim NewFace = L_PartNo.Text.Substring(2, 10)

If filename.Contains(NewFace) Then
        lNewFace.Visible = False
      Else
        lNewFace.Visible = True
      End If

The code below was a translation from the answer in C# but it does not work either

Dim contains As Boolean = Directory.EnumerateFiles(path).Any(Function(f) [String].Equals(f, "myfilethree", StringComparison.OrdinalIgnoreCase))
  • 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-06T13:41:18+00:00Added an answer on June 6, 2026 at 1:41 pm

    Here’s an example of how you can do it without the fancy LINQ and Lambda which seem to be confusing you:

    Public Function FileMatches(folderPath As String, filePattern As String, phrase As String) As Boolean
        For Each fileName As String In Directory.GetFiles(folderPath, filePattern)
            If fileName.Contains(phrase) Then
                Return True
            End If
        Next
        Return False
    End Function
    

    Or, if you need it to be case insensitive:

    Public Function FileMatches(folderPath As String, filePattern As String, phrase As String) As Boolean
        For Each fileName As String In Directory.GetFiles(folderPath, filePattern)
            If fileName.ToLower().Contains(phrase.ToLower()) Then
                Return True
            End If
        Next
        Return False
    End Function
    

    You would call the method like this:

    lNewFace.Visible = FileMatches(path, "*.pdf", NewFace)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a Userform that lets the user pick a worksheet from a
I have created a UserForm where the user is required to fill-in three fields.
I have several checkboxes in a groupbox on a vb 2008 express userform. I
I have an Excel2010 VBA userform that has one comboBox, from which the user
I have a userform that I have created that contains a number of TextBoxes.
I have a UserForm class which has a select list populated from a related
I have just started learning django. I created a form from django models. On
I have the following scenario in MVC2 /VS 2008: A user form with 2
I have a userform that is opened when a user clicks a button in
I have created a userform with three textboxes. The first textbox is for the

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.