VB6 - Reteiving folder name as variable.

Soldato
Joined
4 Nov 2007
Posts
4,514
Google and black book is no help.

Trying to get a folder name (.exe will be within this folder, in 2 sub folders i.e. Z:/Contracts/THISFOLDERHERE/05 Mail/05-08-2008/Application.exe) into a label.

Any clues?
 
Something like this (untested):

Code:
Dim pathElements As String()
Dim path As String

path = "Z:/Contracts/THISFOLDERHERE/05 Mail/05-08-2008/Application.exe"

pathElements = Split(path, "/")

label.Text = pathElements(pathElements.Length - 4)
You may need to adjust the seperator between / or \ depending on where you get the path from, and this assumes that the directory name you're after is in a known position in the hierarchy above the exe.
 
The path won't be static, is there any way of changing "path = ..." to the applications path?

But otherwise it looks like it will work, top notch!
 
Aye, just found that lol

Code:
pathElements = Split(App.path, "\")

Label_date.Caption = pathElements(pathElements.length - 4)

Getting "Invalid Qualifier" on the pathElements.length, label_date.caption is right is it not?

Edit: Assuming it's because the .exe isn't compiled yet, and not in the right folder?
 
Last edited:
Got that working through Left$ and Right$ & and IF statement , Split wasn't playing ball.

Code:
myRecSet.Open "mail_info", MyConnObj, adOpenKeyset
myRecSet.AddNew
myRecSet.Fields("name").Value = MyName
myRecSet.Fields("mail_date").Value = MyDateFolder
myRecSet.Fields("contract").Value = MyContract
myRecSet.Fields("read_date").Value = MyToday
myRecSet.Update

MyConnObj.Close

Erroring on mrRecSet.Addnew, does not allow new data or wrong locktype.
 
Nice one!

All fine and working now, just some GUI tuning needed.

a Msgbox is showing twice for some reason, will paste code tomorrow when back in work.
 
Back
Top Bottom