Obtaining Values from Filenames: A Guide

  • Thread starter DLinkage
  • Start date
In summary, to extract specific characters from a file's filename and append them to a range of cells, you can use the mid function in VB. The 'Office Development' forum within the VB forum is a useful resource for additional help.
  • #1
DLinkage
19
0
I'm trying to read in a file's filename and append part of the filename to a certain range of cells. This is to say if the filename was "ABC12X.txt"
and another filename was "ABC13X.txt", then how could I obtain the values "12" and "13" given the filename information alone? Thanks
 
Technology news on Phys.org
  • #2
Do some string manipulations i guess...I forgot my vb :(
 
  • #4
DLinkage said:
I'm trying to read in a file's filename and append part of the filename to a certain range of cells. This is to say if the filename was "ABC12X.txt"
and another filename was "ABC13X.txt", then how could I obtain the values "12" and "13" given the filename information alone? Thanks

If what you are trying to extract is always the 4th-5th characters, you can use the mid function:

Sub test()
Dim s1 As String
s1 = "ABC12X.txt"
Debug.Print Mid(s1, 4, 2) 'result is 12
End Sub

If you need addition help, the 'Office Development' forum within the following VB forum is great:

http://www.vbforums.com/index.php

Good luck. :smile:
 
Last edited:

1. What is the purpose of "Obtaining Values from Filenames: A Guide"?

The purpose of "Obtaining Values from Filenames: A Guide" is to provide a comprehensive guide for scientists on how to extract meaningful data and values from filenames. This can be particularly useful for researchers who deal with large amounts of data and need to organize and analyze it efficiently.

2. What types of data can be obtained from filenames?

Data such as dates, times, locations, experiment numbers, and sample identifiers can be obtained from filenames. The specific data that can be extracted will depend on the naming conventions used by the researcher or the institution.

3. Why is it important to have a guide for obtaining values from filenames?

Having a guide for obtaining values from filenames can save time and improve data organization. It can also help to avoid errors and inconsistencies in data analysis, as well as facilitate data sharing and collaboration among scientists.

4. Are there any limitations to using filenames for obtaining values?

Yes, there can be limitations depending on the naming conventions used and the complexity of the data. In some cases, filenames may not contain all the necessary information and additional data may need to be recorded separately. It is important for scientists to carefully plan and design their naming conventions to ensure the most relevant data can be obtained from filenames.

5. Is there a recommended approach for obtaining values from filenames?

There is not one specific approach that is recommended for all situations. However, it is generally recommended to use a consistent and logical naming convention, make use of date and time stamps, and include all relevant information in the filename. It may also be helpful to create a guide or template for naming files to ensure consistency and accuracy.

Similar threads

  • Programming and Computer Science
Replies
6
Views
5K
  • Programming and Computer Science
Replies
4
Views
8K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
10
Views
25K
  • Programming and Computer Science
Replies
3
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Replies
9
Views
3K
  • Programming and Computer Science
Replies
2
Views
13K
Back
Top