Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Using App.path In A Module

I can't seem to use app.path in a module

i tried refering like but that doesn't work either

please help

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
App.Path In Module Constant
Hi i'm noob to VB. I'm trying to use app.path in a constant in a form like:

Const d_Svt = App.Path

It obviously doesn't work but how can i make that const the apps path?

Any help great thanks

VB Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity     version=""     processorArchitecture="X86"     name="1234.exe"    type="win32" /> <description>A Description</description><dependency>    <dependentAssembly>        <assemblyIdentity            type="win32"            name="Microsoft.Windows.Common-Controls"            version=""            processorArchitecture="X86"            publicKeyToken="6595b64144ccf1df"            language="*"        />    </dependentAssembly></dependency></assembly>

Retreiving Class Module Parent Path
I am working on a class module and I need to find a way to retreive the path of the project calling the class. I could create a class property where I could set the property of the class equal to the path of the project but would like to avoid if possible. For example:


Private m_sPathName As String

Public Property Get PathName() As String
PathName = sPathName
End Property

Public Property Let PathName(sPathName As String)
m_sPathName = sPathName
End Property


Private Sub Form_Load()
Dim myClass As New clsModule1
myClass.PathName = App.Path
End Sub

If I could figure out a way to avoid setting this property, it would be helpful. Does anyone have any suggestions?

File Path Of Currently Executing Module/application
Anyone know how to retrieve the current path of executing module. Have tried Application.StartupPath and Application.Path but I think these are picking up where modules are expected to be stored under the standard C: drive where VB is installed. I currently store my applications in a different drive. So I suppose is there a way of getting the file path of the current executing module/application.

Transferring Code From Form Module To Standard Module
Good Day eveyrone!

I began writing code in a form module, but now, having expanded my code, i need to merge bunch of code into one module.

I have never programmed withtin a standard module before, if anyone could give "getting started" suggestions

ie what is different how can i reference to objects that are located on form, command dialogue boxes etc.

That would definately help out a greate deal!!

Thank you for your help

Raise Event In A Class Module Through A Module (Thanks To Merri).
Hi everybody , currently I want to make a keyboard hook but as an ActiveX Dll , I use Joacim Andersson's method for doing this , like here it work perfectly but it use AddressOf so I must use a module , my question is : If I have event in my class module say [ Public Event KeyPressed (VirutalKey As Long) ] how can I raise it through the module ?

I know that there is a way in the API Timer made by Wokawidget but I don't know how to use it in my case , can anyone help ?!

Btw : I made a search but nothing relevant if it was discussed be4 I want links please.

Thanks & Have a nice day

- Passing String From Class Module To A Form Or Module
Can I pass a string to a form?

I need to pass a string from a class module to a Form or a Bas module.

The string is declared as a public in the Class module

Code:Public strID as string

However, it won't recognize the string in the module.

Edited by - pbeast on 1/12/2007 5:36:05 PM

How To Raise The Error From The Class Module To The Form Module?
hi buddys

i have one class module with some procedures . in that i am raising some errors with the command err.raise command.

so what my question is that when i am raising this error, these are all raising in the class procedures only. what i want is that that errors has to be handled only in the form methods only not in the class methods. even though i am raising there but is has to come the place in which where the class procedure has been called . here i am using class directly.
plz help me.


Activex.exe - Class Module Or Simple Module ?
Hi ,

I have this activex.exe project I'm working on.
The default module in this kind of project is class , but it seem to have some disadventeges like : can't use public array....

So I've added simple module .

My ques. is in which module it's better to write my code : class / simple ? why ?

Thanks in advance , Moyalt.

A Little Help In Converting Class Module As Public Module !!
I normally use the following class module in the 'notinlist' property of the field to display an error massege and undo changes. Could I have some help in converting this as a public module so that it can be generically used by all forms in the DB. Primarily I am having trouble in pointing to currently selected control and not a specific control (which in this case is DevActivity).

Private Sub DevActivity_NotInList(NewData As String, Response As Integer)
Dim ctl As Control
    ' Return Control object that points to combo box.
    Set ctl = Me!DevActivity
    ' Prompt user to verify they wish to add new value.
    If MsgBox("Please restrict your selection to the listed activities. If in doubt, please contact HR.", vbOKOnly) = vbOK Then

        Response = acDataErrContinue
    End If
End Sub



Troubles In Module - A Very Simple Module &lt;RESOLVED&gt;
I am having troubles understanding this. I created a standard .EXE type project.
On the form I placed an Image Control. Nothing else

Code:Option Explicit
Dim FName
Dim F1Name
Dim pPath

Private Sub Form_Load()
    pPath = App.Path
    F1Name = "2.jpg"
    FName = pPath & "" & F1Name
    LoadPicBox1 (FName)
End Sub

Then I added a Module like this

Code:Option Explicit
Public PicName
Public FName As String
Public Image1 As Control

Public Sub LoadPicBox(FName As String)
    Image1.Picture = LoadPicture(FName)
End Sub

When I press F5 I get an error that says 'Object Variable or With Block not set'
and it points to the 'Image1.Picture = LoadPicture(FName)' line in the Module.
Why? What am I doing wrong?


GOD said it, I believe it, so that settles that.....

Edited by - kf4iis on 7/29/2003 4:58:31 PM

Difference Between Standard Module And Class Module
what is the difference between standard module and class module?

Can We Change The Code Of A .bas Module(Standard Module)

              I am doing Licencing of Software's Project.
              It is almost over. But i am facing one problem. It is eating my head. Please help me.

              There r two modules in my project(Licence Manager Pjt). First one(mgr side) is independent from second one(Client side).

              In first module LicenceManager enteres a file name at runtime. That is Stored in to a variable "FILE_NAME". Now i want to enter code in to the XYZ.bas module as follows
     Code:Public Const FILE_NAME_ENTERED = "FILE_NAME"

Remember that This XYZ.bas module is in Second part of my project.
            Sothat when my first module is executing i am changing the code of "FILE_NAME" in XYZ.bas standard module

            Now after compleating the execution of first module,I am going to compile and execute my second module , in which i added that XYZ.bas to my project. Sothat i can read the Constant variable FILE_NAME_ENTERED and its data value in my program.

         This is my problem..

         I think this can be done by using VProject, VBComponents Class collections. By using this we can get reference of that .bas module. I tried that one But it is showing errors.
       I am using Visual Basic 6.0 . and i wrote following code in the form module.

Code:1.    Dim VBProj As New VBProject
3.    Private Sub Form_Click()
4.     Set VBProj = ActiveVBProject
5.     MsgBox VBProj
6.    End Sub

        I checked the Microsoft visual basic 6.0 in the Projects -> Refereneces Dialog

        But it is showing Error at Line No: 4 > Object Reguired (424)

                I gothrough the following link. There they explained about this topic.
    Adding .bas modules , Changing code, deleting code in .bas etc... for Excel WorkSheets
        But i dont know how to implement the same concepts in my project. I think it is possible to u . please reply me soon.

         Click Here: For Programatical Way

        Is there any other alternative to do same thing.

        ie i want to read "FILE_NAME" from Licence Manager in part 1, and i have to use that file name in part 2 of my project.where ever that "FILE_NAME" variable appears, i want to use its value from "FILE_NAME" which is entered in Part1.

         Send me ur valuable thoughts.

         I am waiting for ur reply....


Module And Class Module Problem
i have a main function that run in class module and then access a function through a function in module.

for instance, in class module a function named "client" calling a function in module named "convert".

the convertion will work if i call the function "convert" in module.

but the problem generate when i put the same convert function in "client" class module and calling the same name ( instead of calling "convert" from module, i call from class module). ....... then the convertion fail....

i have no idea why this happen, i am new to VB program and just started to learn. i don't have a proper trainning from school, so i don't know if i can call the function in class module....

will they perfom the same when function is in module and class module ...

please educate me ............

Difference Between Module And Class Module!?!
Is there a difference between "Module" and "Class Module"?

Why would I use "Module" if "Class Module" exist and do the same with possible Event handling add-in

Class Module && Standard Module
I have one class module and one standard module in the same ActiveX DLL project, and I can't access the class from the module. Is it me, or that is perfectly normal?
I had to: keep a reference of the class (well, the object) in the module, set it from the class in the Initialize event and use in to call a method of the class from the module... was it necessary??

The same happens with an UserControl & standard module in the same ActiveX Control project.

Difference Module And Class Module ??

Please help me to get some DETAILED knowledge about the following

What is the difference between a "Module" and a "Class Module”?
When to use a "Module" and, when to use a "Class Module” ?
What is a type how to use it?
How to register a new control or a dll file, created in vb? Is it necessary to copy the dll file in same directory in which the project is saved?

what step should be take to dealing with registry?


Difference Between Module And Class Module
What is the difference of Module and Class Module in VB?
I want to add a module in my project, but i saw Class Module..what is that?
What a dumb question...but at least i ask...

Difference Between Module And Class Module
can someone explain the difference between a Module and Class Module i've used both but dont seem to see much difference ( i've put code in a module in a class module and vise versa and the program has stilll worked fine)

Difference Between Module And Class Module
Hi Guys,
Where can i use module and not in vb and
where can i use class module and not in vb.

Thanks in advance.

What The Difference Between A Module And A Class Module?
i know, u guys probably get that question alot...
i read some stuff about both og the above, but i don't understand
the DIFFERENCE. try making your replay an explanation for dummies...

How Can I Create A XXX.bas Module(Standrad Module)

              I am doing Licence Mgt Pjt, Which contains 3 parts. In first part i am reading some file name from licence Manager.
         Now , in second part(client side) i want to use that file name in my code .

         The problem is there is no relation ship between part1 and part2.
     What i want is "When Licence Manager enters a file name, I want to create xxx.bas module and i want to place some code in that
      Public Const FILE_NAME_ENTERED = " file name"
 Sothat i can add that module to my second part and i can access the file name

             Is it possible (or) r there any alternative to it.
Please help me.
         Thanks in advance....

     I am waiting for reply from vbmasters.....

Difference Between Module / Class Module
I have created/used classes in VB.NET before, and have no problem with that. I have little experience in working with VB6 and would like to create some classes to cut down on the form code. I see that there is a module and a class module. I would like to know which is better to use and the difference between the two.

Difference Between Module And Class Module
I am going to add threading to my program and have been reading and studying this post . I have my program complete, but the functions I want to use for threading are in a Module, and in the example the threaded function is in a Class Module. Can I just copy my code from the Module to a Class Module without any problems? As far as I can tell the two aren't any different code wise.. ?


Difference Between Module And Class Module
What is the difference between class module and module? also, which one would be the best to use????


Get A Network Files Local Path From Its UNC Or Mapped Drive Path
After a user browses for a file, if it is a network file I want to get the path that is local to that networked computer. For example if I have a mapped drive named "N:" which maps "\ServerShared" which is "C:Shared" on the server, if a user browses for a file and selectes "N:MyFile.txt" or "\ServerSharedMyFile.txt" I want to get the path that is local to Server, which is "C:SharedMyFile.txt". I have been searching the forum with no luck but if it is out there and you could please point me in the right direction... Thanks!

Mapping Windows System Folder To Application Path(EXE Path)
Dear all,

My problem is this :

I am using an ocx's for flex grid & Image edit for displaying data & images.

I want to keep my EXE file & the supporting files in CD, so that anyone can run this application from CD.

I don't want to do installation package & also not to register the ocx files. Instead of this I'll keep my supporting files along with EXE in CD.

I want to map system folder to my app.path (in CD), so that my application will run taking supporting files in CD rather than windows system folder.

Here I'm stuck.

By doing this I can avoid regestering OCX or developing package.

Please help me to solve this problem.


Dir(path && Filename) Error If Path Is To Cdrom?
i always get an error in my code

Dir(path & filename)
if path is a drive letter for cd rom...
how can i avoid this error?

VB RunTime 76 Invalid Path Name; Path Not Found. Please Help
I am writing an application that the user inputs three things. 1. Path To List 2. Path To Save Text File 3. Name of text file. The user inputs the Path To List and presses the List Files button. Then the user inputs the Path to save the file, and 3rd the name of the file. Then they press transfer which moves the list from the FileListBox to the ListBox and then writes a text file of the list. If the user inputs a nonexisting directory they will get a RunTime 76 error invalid path name; path not found. I was wondering if there was a way to test to see if a directory path is valid. Please Help! any help is extremley appreciated.

Path Not Found Error, But Path Exists
I am getting a path not found error on the highlighted line, but the thing is, the path is found. i tried to debug and the information seems right.

VB Code:
Private Sub cmdSaveFile_Click()    m_strProjectsDirectory = "Projects"    m_strBackupDirectory = "Backups"    m_strSaveProjectFileName = txtFileName.Text    m_strSDPROJFileName = m_strSaveProjectFileName & ".sdproj"    m_strFileNameLocation = App.Path & "" & m_strProjectsDirectory & "" & m_strSDPROJFileName        If Len(Dir$(App.Path & "" & m_strProjectsDirectory & "", vbDirectory)) > 0 Then        'do nothing because the Projects directory exists    Else        MkDir (App.Path & "" & m_strProjectsDirectory & "")    End If        If m_strSaveProjectFileName = vbNullString Then        MsgBox "You must input a filename!", vbExclamation, "Error Encountered."        Exit Sub    ElseIf LCase(Right$(txtFileName.Text, 7)) = ".sdproj" Then        MsgBox "Input your file name, excluding the file extension.", vbInformation, "Error Encountered."        Exit Sub    End If        If FileExists(m_strFileNameLocation) Then        m_intMsgBoxAnswer = MsgBox("The file name that you have specified is already in use." & vbNewLine & _                                   "Would you like to overwrite this file?", vbExclamation + vbYesNo, "File Name in Use.")        If m_intMsgBoxAnswer = vbNo Then            MsgBox "The file has not been overwritten" & vbNewLine & _                   "and has not been saved anywhere.", vbInformation, "File Not Overwritten."            Exit Sub        Else 'If vbYes Then            If Len(Dir$(App.Path & "" & m_strBackupDirectory & "", vbDirectory)) > 0 Then                'do nothing because the backup directory exists            Else                MkDir (App.Path & "" & m_strBackupDirectory & "")            End If                    'copy the file to the backup directory, date and time stamp it so as to prevent file copy            'problems            [hl]FileCopy m_strFileNameLocation, App.Path & "" & m_strBackupDirectory & "" & Date & Time & m_strSDPROJFileName[/hl]                    'delete the file from the original directory            Kill m_strFileNameLocation                    'rewrite the file            WriteProjectFile                        'inform the end user            MsgBox "The file has been overwritten as requested. Please note that" & vbNewLine & _                   "the file was also backed up for you and placed within the" & vbNewLine & _                   "backup directory." & vbNewLine & vbNewLine & _                   "The location of the backup directory is:" & vbNewLine & _                   App.Path & "" & m_strBackupDirectory & "" & vbNewLine & vbNewLine & _                   "The name of the backed up project file is:" & vbNewLine & _                   Date & Time & m_strSDPROJFileName, vbInformation, "File Overwritten."        End If    Else 'file name not in use        WriteProjectFile    End If        Unload MeEnd Sub

Convert UNC Path To Local Drive And Path
I thought there was a way to do this but I can't remember it. Ho can you convert a UNC path back to a local drive and path (mapped or local). I believe there was an API but I can't find it.

ex. \serverdevelopment converts to Z:Development

Find The Path, Enter Path Into String
What I want to do is search for a file on a drive and have
the path name entered into a string... for example pth$

Print #2, "C:"
Print #2, "CD"
Print #2, "CD Program*" < Prob 1
Print #2, "CD America's*" < Prob 1
Print #2, "CD System"
Print #2, "CD Save" < Prob 2
Print #2, "CD save" < Prob 2
Print #2, "DIR /A /O:D > C:" & ID$ & "save.LOG"

Also I have the following problems with the code above.
1. There are two directory's that are named "CD America's"
The problem im having is I canot use spaces and have to use a astrix.
2. Case sensitive for going down directories.


File Path Withouth Application Path
Hi all,

my program uses some sub directories to store data in it. The user can select files through a common dialog (file open) control.

What i need is the location of the file WITHOUT the application path/folder. So something like

app.path = c: estapplication1

filelocation = c: estapplication1files est1.txt

result (what i need) should be then = files est1.txt

Any ideas about this one?



How To Set The Current Drive And Path To A Network Path?
Hi everybody,

In my client's office, there is a Windows 2000 Advanced Server computer and several Windows 98 workstations connected to it. From a workstation computer I want to set the current drive and path to "\ServerServer eMarket". Is that possible without mapping the network drive?

How Can I Conver A Short Dos Path To Windows Path?
How can I conver one of those shortened paths like msdos paths to windows paths (the actual file is not shortened)
(like when you have progra~1 instead of program files)

Convert A Long Path Name To A Short Path Name (8+3)

Does some one could tell me how could i convert a long path name to a short path name (8+3)

For exemple :



Thank you for your help.....

Help With Path Of File / Shell Program Path
Currently I am using the shell command to open an application called Kodakprv.Exe. Their are going to be multiple users for my application and of course the Kodakprv.Exe is in a different directory on each PC. Is their a way to find the directory that the kodakprv.Exe is in and then use that as Path in the shell command to open Kodakprv.Exe. Any help would be greatly appreciated.

Here is the code I have now


sAppName = Trim(strImageName) & " - Imaging Preview"
intRet = Shell("C:Program FilesWindows NTAccessoriesImageVuekodakprv.exe \lightfootd-drivewebsecurescanimages" & strImageName, vbNormalNoFocus)

TEMP Path? System Folder Path?

i need to extract a temporary file onto my clients computers, and i want this file to go to the windows temporary directory, (e.g. c:windows emp or c:winnt emp)

is there a way to find this temp directory on the clients machine and then set that into a string to use? because some operating systems have different paths to their temp directory, my script must be dynamic


Edited by - Ahmz_055 on 12/11/2004 4:59:01 PM

How To Obtain Relative Path From Absolute Path?

How do I obtain the relative path (e.g. "....Test.tmp" ) from the absolute path ( "C:Test.tmp" ) with respect to a directory (e.g. C:Temp2Dir2 )? This should work irrespective of where the file Test.tmp is stored.
Do you have any sample code which could help me do this?

Any help would be greatly appreciated.

Thanks and Regards,

Application Path Or File Path I Am Not Sure
I have a very small exe that is written in vb6.0 It is so small it doesn't require any setup program to run it.

So here is my question. When the user moves the exe to a folder on load I want to display the location of the exe to the user if they request it and to load the proper help files if they have moved them along with the exe.

Does anyone have any sample code of how to do this. I am sure it could be done with an api call, but wouldn't know where to start.

Any help as always is greatly appreciated.


Path Location Problem Dir.path
I have problem here.. i have textbox that store path location. It show in the textbox as C:\ . How I can show in the textbox as C: ?

Dir1.Path = Text1.Text

Getting File Path From Full Path And Name
Let's presume I've got a path as follows :

I want to get :
only, so I don't want the file name.

I tried this :

NewFName = Mid(FName, InStrRev(FName, "") + 1) & "Output"
If Not FoldCreated Then
MkDir NewFName
FoldCreated = True
End If

But, I got the filename?
How can I change this to get the path only??

Network Path To Local Path
I have an application that remotely installs a service in some stations.
I use path: \MachineNameAdmin$ for the installation of the service.
Somebody knows a way to return the local path through \MachineNameAdmin$ ?
Example: Passing \MachineNameAdmin$ would return c:winnt


How To Extract Path From Path+exename ?
Anybody have code that will allow the path to be extracted from the full path of a file , for example,

d:documents and settingsmyypcfile1.exe

well i need to extract just,

d:documents and settingsmyypc


Local Path To Net Path... Simple?
how can i convert:





Compating Database... How Do I Set The Path With App.Path?
this is my code I have but i get an error. It changes the path name of where my database is. I have a connection to 2 different databases in this form and some reason it gets the path for the other database +databaseWMdbase.mdb

so it shows up like this.


all I want it to do is go here


I tried using app.path but it puts app.path in the file name... I don't know what the deal is...

Me.MousePointer = 11
'declare variables
Dim objJRO As JRO.JetEngine
Dim strConnSource As String
Dim strConnDestination As String

'set connection string info
strConnSource = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=databaseWMdbase.mdb"
strConnDestination = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:Temp.mdb"

'instantiate object
Set objJRO = New JRO.JetEngine

'compact database from source to destination
objJRO.CompactDatabase strConnSource, strConnDestination

'release objects
Set objJRO = Nothing
Me.MousePointer = 0

FileCopy "c:Temp.mdb", App.Path + "databaseWMdbase.mdb"
Kill "c:Temp.mdb"
Killcn CN

Path Finding.. Then Moving Along The Path..
Ok, what I am wanting to do is make a simple car racing game. where there is a simple track but there are obviously different parts of the road to drive on, and some cars will pick the fastest (racing line) others wont (stupid line).
So whilst browsing the forums I came accross this link:

It's all about Dijkstra's path finding algorithm, and it all works very well and all that, but how would I actually move a object along the path? And at varying speeds?

So my question is can anyone give me the code, or show mw a site that shows a very simple program that makes a picture go around a simple shape, like a rectangle?

App.path Gives Back The Wrong Path
My project used to be in a directory that has been renamed. If I run my program now the app.path gives back the wrong directory.

- original directory : colos_touch
- new directory : colostouch

--> app.path gives back : colos~1

Does anyone have any idea how this can be solved ?


Jan Be(lgium)

Counting The Documents/path In A Path
Hi I have following problem.
There is a path like c: estthis path is named as testpath
now I need to count the pathes wich are in this testpath. After that I need to get the names of each path.
How can I realise that?
Thanks for your help,

Problem With File1.path = App.path
There was an error message popup "Method or data member not found" which also highligted "path" of the File1.path.I wish to set the filelistbox to the My Pictures directory so the pictures could be displayed in the list.
The code I refered is like this

Private Sub Form_Load()
File1.Path = App.path

Did I missed something ?

Copyright © 2005-08, All rights reserved