Obtaining Values from Filenames

  • Thread starter Thread starter DLinkage
  • Start date Start date
AI Thread Summary
To extract specific parts of a filename in VBA, such as the numbers "12" and "13" from filenames like "ABC12X.txt" and "ABC13X.txt," string manipulation functions can be utilized. The Mid function is particularly useful for this purpose. For example, using Mid(s1, 4, 2) allows you to retrieve the 4th and 5th characters of the string, effectively extracting the desired numeric values. For further assistance and resources, the 'Office Development' forum on VBForums is recommended for additional support in VBA programming.
DLinkage
Messages
17
Reaction score
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
Do some string manipulations i guess...I forgot my vb :(
 
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:
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Replies
10
Views
1K
Replies
18
Views
6K
Replies
4
Views
9K
Replies
4
Views
2K
Replies
3
Views
5K
Back
Top