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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:18:04+00:00 2026-06-13T05:18:04+00:00

I have a filepath that I would like to pull the starting directory job

  • 0

I have a filepath that I would like to pull the starting directory job number from the beginning of the filepath. Except I don’t know how to just pull the number string out of the filepath string. (i.e.: filepath= Q:\2456_blah_blah\file.txt – or something) I’d like to just pull ‘2456’ as a string,
then put that number string into TextBox2 I’ve created on my form.
The code I have so far spits out a ‘0’ instead of the number string desired.
Any help would be much appreciated.

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Me.OpenFileDialog1.FileName = Nothing

    If Me.OpenFileDialog1.ShowDialog = System.Windows.Forms.DialogResult.OK Then
        Me.TextBox1.Text = Me.OpenFileDialog1.FileName

    End If

    If GetInfo() = True Then

        For Each Xitem In ExcelRowList

            Dim lvitem As ListViewItem
            lvitem = Me.ListView1.Items.Add(Xitem.C1)

        Next

    End If
'''Here is where I call the GetFilePathOnly function
    TextBox2.Text = GetFilePathOnly(TextBox1.Text)
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

End Sub
'''Section below is what defines my number string, then I call it above for the Button1.Click operation(towards the end)
Private Function GetFilePathOnly(ByVal Fullpath As String) As String
    Dim File As String = Fullpath
    Dim number As Double = Val(File)
    Dim outcome As String = number.ToString 'File.Substring(0, File.LastIndexOf("\") + 1)
    Return outcome
End Function

Thanks

  • 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-13T05:18:05+00:00Added an answer on June 13, 2026 at 5:18 am

    You could also use a regular expression easily.

    Dim numRegex As New Regex("\d+")
    Dim number As String = numRegex.Match("Q:\2456_blah_blah\file.txt").Value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this issue working but i would like to know if there is
I have the following: @Html.NavLinks(@Model.menuItems, (string)ViewBag.FilePath) Now I would like to add another parameter
I have an in-memory cache that I would like to write out to file
To start I would like to clarify that I'm not extremely well versed in
I have a picture which I would like to open with thewindows Picutre and
Hey guys, I have an application that I want to display some data from
I have some code that is returning a XNode to me which looks like
I have a block of C# that looks like this public static string[,] FileTypesDict
I have a hybrid (Objective C + HTML) application and I would like to
I have a singleton class that will initialize it's data from a web service

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.