trim path PLEASE HELP newbie - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

trim path PLEASE HELP newbie

findepterfindepter Posts: 5Member
Hi all, I'm a newbie so please forgive me if i mess this up :-)
I am working on a new vb app in vb 2008 that works of a database. What i want to do is store a short image path to the database field (the picture is displayed on a vb form.)
Anyway, i can get the full path of the picture but i want to crop it to just everything AFTER the appication.startuppath, IE:

I get image path as: C:UsersmeDocumentsVisual Studio 2008Projectsmydbapppicturelocalimage1.jpg
I then store this in a textbox, now i want to retrieve everything EXCEPT the application path which in this case is 'C:UsersmeDocumentsVisual Studio 2008Projectsmydbapp' so i just get
The application path will change once it is rolled out hence i just store the short image path in the db and manually add application.startuppath in code so as it will always work (in theory!!)
PLEASE HELP ME ASAP, i have googled all day and not been able to solve it.

Many thanks in anticipation of your answer


  • dokken2dokken2 Posts: 532Member
    I don't have VS-2008, but can use string functions to find your project path. Since you know the FullPath from Application.Startuppath and I assume the Visual Studio path will not change, you can determine what string is "at the end of the visual studio path".

    'define the visual studio path
    Const VSpath = "C:UsersmeDocumentsVisual Studio 2008Projectsmydbapp"
    Dim FullPath As String
    Dim AppPath As String

    'fullpath = application.startuppath
    FullPath = "C:UsersmeDocumentsVisual Studio 2008Projectsmydbapppicturelocalimage1.jpg"

    Dim CharPos As Integer
    'determine start of characterposition of vspath within the fullpath
    CharPos = InStr(FullPath, VSpath)
    'add length of vspath
    CharPos = CharPos + Len(VSpath)
    'extract your apppath from within the fullpath
    AppPath = Mid(FullPath, CharPos, Len(FullPath))
    MsgBox AppPath
Sign In or Register to comment.