ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 5.0 compatability problem? (https://www.excelbanter.com/excel-programming/300545-excel-5-0-compatability-problem.html)

Bob Phillips[_6_]

Excel 5.0 compatability problem?
 
Bill,

I guess that it is telling you that Default is a reserved word that you
cannot now use as a variable name.

The other looks like testing a string for False won't work. Try changing the
declaration of LotReq to variant.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Bill C" wrote in message
...
I wrote a macro using Excel 5.0 and it has been running great for several
years using 5.0 but client has upgraded to newer version of Excel and
problems exist.
Dim LotReq As String
Message = "Choose ""OK"" For All Lots, Or " & Chr(13) & "Enter
Lot Number Requested."
Title = " CHOOSE LOT"
Default = "ALL"
LotReq = InputBox(Message, Title, Default)
If LotReq = "" Or LotReq = False Then EndAll

The following statements are not working:
Default = "ALL" ( get error about const assignment )
If LotReq = "" Or LotReq = False Then EndAll ( stops program )
Also Excel appears to be returning "false" on this statement when Pmts =
0.00
If Pmts = False Then EndAll

I do not have access to current Excel program. Can anyone spot the

problem?

TIA,
Bill C.





Myrna Larson[_3_]

Excel 5.0 compatability problem?
 
Current versions of VBA support "named arguments" (equivalent to built-in variable names).

In the case of InputBox, the names of the 1st 3 arguments are Prompt, Title, and Default.

Excel is probably getting confused by your use of Title and Default as variable names. Try
changing them, perhaps by adding an underscore at the end: Title_ and Default_

Names arguments allow you to supply the arguments in any order if you use the syntax like this:

LotReq = Inputbox(Title:=Title_, Default:=Default_, Prompt:=Message)

As for the problem with the comparison, first let me say that it works for me in Excel XP. If I
write

Dim x As String
x = "0.00"
Debug.Print x = False

It prints True.

But if this isn't working for you then I would convert the string to a number using the CDbl
function, then compare with the numeric value 0:

If LotReq = "" Or CDbl(LotReq) = 0 Then EndAll

I assume EndAll is the name of another sub?

PS: It's a good idea to Dim all of your variables. There are no Dim statements for Message,
Title, and Default.


On Sun, 6 Jun 2004 13:51:01 -0700, "Bill C" wrote:

I wrote a macro using Excel 5.0 and it has been running great for several
years using 5.0 but client has upgraded to newer version of Excel and
problems exist.
Dim LotReq As String
Message = "Choose ""OK"" For All Lots, Or " & Chr(13) & "Enter
Lot Number Requested."
Title = " CHOOSE LOT"
Default = "ALL"
LotReq = InputBox(Message, Title, Default)
If LotReq = "" Or LotReq = False Then EndAll

The following statements are not working:
Default = "ALL" ( get error about const assignment )
If LotReq = "" Or LotReq = False Then EndAll ( stops program )
Also Excel appears to be returning "false" on this statement when Pmts =
0.00
If Pmts = False Then EndAll

I do not have access to current Excel program. Can anyone spot the problem?

TIA,
Bill C.



Bill C[_2_]

Excel 5.0 compatability problem?
 
I wrote a macro using Excel 5.0 and it has been running great for several
years using 5.0 but client has upgraded to newer version of Excel and
problems exist.
Dim LotReq As String
Message = "Choose ""OK"" For All Lots, Or " & Chr(13) & "Enter
Lot Number Requested."
Title = " CHOOSE LOT"
Default = "ALL"
LotReq = InputBox(Message, Title, Default)
If LotReq = "" Or LotReq = False Then EndAll

The following statements are not working:
Default = "ALL" ( get error about const assignment )
If LotReq = "" Or LotReq = False Then EndAll ( stops program )
Also Excel appears to be returning "false" on this statement when Pmts =
0.00
If Pmts = False Then EndAll

I do not have access to current Excel program. Can anyone spot the problem?

TIA,
Bill C.




All times are GMT +1. The time now is 01:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com