|
-
May 8th, 2007, 12:18 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Exploring directories
I'd like to be able to depend only in the hierarchy of the directories of my project files and no in which computer, unit or server the whole project is located.
For most of the file paths I use Application.CurrentProject.Path (in this case for Access).
Suppose your file lies in directory H:\XXX\YYY\ZZZ
But in H:\XXX\ you have either:
- H:\XXX\YYY, and
- H:\XXX\RRR
Is it possible to get the current directory string, go up two directories and then just add to this string "RRR" so that you are now in H:\XXX\RRR?
This should be possible by manipulating the string and searchin character \.. but is there some other way to programm this?
Last edited by Fonty; May 9th, 2007 at 11:11 AM.
-
May 8th, 2007, 12:33 PM
#2
Re: Exploring directories
Hi
One way I can think of is using the mid function to check for "\" and then adding the "RRR"
for example
vb Code:
Private Sub CommandButton1_Click()
Strg = "H:\XXX\YYY\ZZZ"
Count = 0
For i = 1 To Len(Strg)
If Mid(Strg, i, 1) = "\" Then
temp = Mid(Strg, 1, i - 1)
Count = Count + 1
If Count = 2 Then Exit For
End If
Next i
strg2 = temp & "\RRR"
MsgBox strg2 '<==== this will give you "H:\XXX\RRR"
End Sub
Hope this helps...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
May 8th, 2007, 02:23 PM
#3
Member
Re: Exploring directories
One way you can do this is to make an array of strings and then join them to make your new path
Dim temp(2) as string
temp(0)="H:\"
temp(1)="XXX\"
temp(2)=Name
temp(3)=".xls"
newstring=join(temp, "")
now newstring will now equal H:\XXX\Name.xls
therefore, you just change out your second value in the array, temp(2) and rejoin
-
May 8th, 2007, 02:30 PM
#4
Re: Exploring directories
Hi Brellis
just a thought...
how will you decide what value does temp(1) hold during runtime...
Right now we are just taking a fixed string as
Strg = "H:\XXX\YYY\ZZZ"
It will be simple to store the path in Strg during runtime in the code which I provided...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
May 8th, 2007, 03:32 PM
#5
Member
Re: Exploring directories
my bad, i thought Fonty already had the path. If he is getting the path on the fly I'd use your method, or do what I was talking about and I'd use the split command
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|