Reputation: 45
I am working with files and I need to pull a substring to insert into a database. Each underscore is the break point for the file and I need to make code that will create a substring that ends at an underscore
Here are what the file names look like
20150225_1291223_FO_8a168549-a520-4f93-b607
20150226_88959_FO_1a2c912c-a4e5-459a-992b-a75991e63df1~20150326_151437
As you can see the values "1291223" and "88959" so I cannot just hard code a start and end point for the substring
Upvotes: 1
Views: 99
Reputation: 1321
This isn't properly error-checked, but you get the idea. Use Split
and separate by "_".
Dim sFilename As String = "20150225_1291223_FO_8a168549-a520-4f93-b607"
Dim sSplitUp() As String = sFilename.Split("_")
MessageBox.Show(sSplitUp(1))
Upvotes: 1