Thread: Boolean Misread
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Charles Chickering Charles Chickering is offline
external usenet poster
 
Posts: 272
Default Boolean Misread

Just a shot in the dark but.... I think VBA interprets True and False as -1
and 0 respectively where as your API call might be using 1 and 0. Perhaps you
could try typecasting the response from your API call:
FtpFail = CBool(ApiCall(ApiParams))

--
Charles Chickering

"A good example is twice the value of good advice."


"ben" wrote:

Hmm evidently The VBA Boolean Type and the value returned from the API call
weren't matching, by removin "As Boolean" in the Dim FtpFail Statement it
worked as intended.
--
When you lose your mind, you free your life.
Ever Notice how we use '' for comments in our posts even if they aren''t
expected to go into the code?


"ben" wrote:

result = msgbox "I don't know what's going on!"
it didn't read as true or False
and btw I had a laugh about my misnamed variable
--
When you lose your mind, you free your life.
Ever Notice how we use '' for comments in our posts even if they aren''t
expected to go into the code?


"Doug Glancy" wrote:

ben,

It looks like your variable is misnamed. Shouldn't FtpFail be called
FtpSucceed? However, I don't think that's the problem. Maybe you should
try explicitly testing for False before Else:

If FtpSucceed = True Then
MsgBox "Order has been successfully Exported."
ElseIf FtpSucceed = False Then
MsgBox "Order has been saved but it has not been exported. Please
check your connection to the internet and try again."
Else
MsgBox "I don't know what's going on!!!"
End If

hth,

Doug

"ben" (remove this if mailing direct) wrote in
message ...
If FtpFail = True Then
MsgBox "Order has been successfully Exported."
Else
MsgBox "Order has been saved but it has not been exported. Please check
your
connection to the internet and try again."
End If

FtpFail is a global Public Variable Dimmed as a Boolean
The variable is read by an API call to write a file to an FTP server
Even if FtpFail = True (by stepping through the program and a msgbox and
debug message I always get true, and the file actually writes) it always
Displays the error message for False, regardless of what the value of
FtpFail
actually is. am i doing something wrong?



--
When you lose your mind, you free your life.