473,379 Members | 1,216 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

run time error '5': invalid procedure call or argument

Hi i am working on an application.in where i have to declare a global variable to access a file path of one document and it should be used in different modules.
i declared the global variable and assiged the value to the variable also.

Expand|Select|Wrap|Line Numbers
  1. Global FilePath As String
  2.  
  3. Function getFilePath() As String
  4.     getFilePath = FilePath
  5.     FilePath = "C:\quadyster\R3AgreementDetails"
  6. End Function
But while using the global variable it is showing empty value i was not getting where i made the error please show me some solution to that
Jun 27 '18 #1

✓ answered by twinnyfo

You need to switch lines 4 and 5:

Expand|Select|Wrap|Line Numbers
  1. Public FilePath As String
  2.  
  3. Function getFilePath() As String
  4.     FilePath = "C:\quadyster\R3AgreementDetails"
  5.     getFilePath = FilePath
  6. End Function
Also, I would recommend using the Public statement, rather than Global, as this is a more standard statement.

3 4145
twinnyfo
3,653 Expert Mod 2GB
You need to switch lines 4 and 5:

Expand|Select|Wrap|Line Numbers
  1. Public FilePath As String
  2.  
  3. Function getFilePath() As String
  4.     FilePath = "C:\quadyster\R3AgreementDetails"
  5.     getFilePath = FilePath
  6. End Function
Also, I would recommend using the Public statement, rather than Global, as this is a more standard statement.
Jun 27 '18 #2
NeoPa
32,556 Expert Mod 16PB
Indeed. In your original code you set getFilePath with FilePath before you'd set FilePath, so it was still an empty string.

Strangely enough, if you'd called it a second time it would have worked ;-)
Jun 27 '18 #3
Thanks for the solutions given i made the changes and it is working fine.
Jun 29 '18 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: mork | last post by:
I am so frustrated - any help is appreciated. When trying to use common functions like Left and/or Mid I get the following error: Run-time Error '5': Invalid Procedure Call or Argument In my...
1
by: Terry | last post by:
Hi. We had a in-house program that use a PRINTLBL.EXE to print label in DOS mode. after the label was printed, Window XP will issue the error message ( Invalid procedure call or arguments ). But if...
5
by: Matt | last post by:
I am receiving the following error from the simple script below. This works fine from a .NET form but when I access the dll from a Classic ASP page it fails. Microsoft VBScript runtime error...
0
by: AparnaKulkarni | last post by:
Hello, I m working with Templates in MS Word. I have established the user Template locations in Word with ".dot" file But after that I m getting error as "Invalid procedure call or argument...
25
by: dennijr | last post by:
ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong heres the simplist code possible: Private Sub IExplorer_Click() a = Shell("C:\Program...
1
by: PrakashN | last post by:
Hai I have done validation for mandatory fields when adding a record in a Button click event.if i click that button using shot cut keys without selecting the option, i m receiving...
3
by: CD Tom | last post by:
Don't know if this is the correct place to ask this but here goes. Heres' what happens, I compile my program and using the XP Developer I run the package wizard on by desktop computer this works...
13
by: sasasasa | last post by:
Hi, I am getting the error saying 'Invalid Procedure Call' in my query. My query is very simple. I am just getting data from another query which is getting data from a table. SELECT ...
0
by: ram27149 | last post by:
Hi I am using a software which is based on vb6.0. While am running the antivirus i have lost the .exe file in the software package. Is there any way to fix the problem i just want to re install...
2
by: vickyanusha | last post by:
I tried to run a batch file using shell command. my code is as below. it throws an error run time error:5, invalid procedure call and on debut it points out the shell command line. pl clarify and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.