PC Review


Reply
Thread Tools Rate Thread

Boolean Misread

 
 
=?Utf-8?B?YmVu?=
Guest
Posts: n/a
 
      13th Feb 2007
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.

 
Reply With Quote
 
 
 
 
Doug Glancy
Guest
Posts: n/a
 
      13th Feb 2007
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" <&&&&(E-Mail Removed)(remove this if mailing direct)> wrote in
message news:81D948D5-8F55-4F2B-8962-(E-Mail Removed)...
> 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.
>



 
Reply With Quote
 
=?Utf-8?B?YmVu?=
Guest
Posts: n/a
 
      13th Feb 2007
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" <&&&&(E-Mail Removed)(remove this if mailing direct)> wrote in
> message news:81D948D5-8F55-4F2B-8962-(E-Mail Removed)...
> > 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.
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?YmVu?=
Guest
Posts: n/a
 
      13th Feb 2007
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" <&&&&(E-Mail Removed)(remove this if mailing direct)> wrote in
> > message news:81D948D5-8F55-4F2B-8962-(E-Mail Removed)...
> > > 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.
> > >

> >
> >
> >

 
Reply With Quote
 
=?Utf-8?B?Q2hhcmxlcyBDaGlja2VyaW5n?=
Guest
Posts: n/a
 
      13th Feb 2007
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" <&&&&(E-Mail Removed)(remove this if mailing direct)> wrote in
> > > message news:81D948D5-8F55-4F2B-8962-(E-Mail Removed)...
> > > > 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.
> > > >
> > >
> > >
> > >

 
Reply With Quote
 
Doug Glancy
Guest
Posts: n/a
 
      13th Feb 2007
I don't know much about APIs but I think Charles is right about the
different interpretations of True and False between Excel and APIs.

If it was me, I'd try to find out what value the API returns for success and
failure and then declare a variable of that type (long?) and just test for
the 2 values.

hth,

Doug

"Charles Chickering" <(E-Mail Removed)> wrote in
message news:E837D88E-FA4A-493B-9BC3-(E-Mail Removed)...
> 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" <&&&&(E-Mail Removed)(remove this if mailing direct)> wrote
>> > > in
>> > > message news:81D948D5-8F55-4F2B-8962-(E-Mail Removed)...
>> > > > 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.
>> > > >
>> > >
>> > >
>> > >



 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      13th Feb 2007
Just to add, you could do


If FtpSucceed Then

Any non-zero value will be evaluated as True

Change the order of your if statement.


If FtpFail Then
MsgBox "Order has been saved but it has not been " & _
"exported. Please check your connection to the internet and try again."
Else
MsgBox "Order has been successfully Exported."
End If


--
Regards,
Tom Ogilvy


"Charles Chickering" <(E-Mail Removed)> wrote in
message news:E837D88E-FA4A-493B-9BC3-(E-Mail Removed)...
> 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" <&&&&(E-Mail Removed)(remove this if mailing direct)> wrote
>> > > in
>> > > message news:81D948D5-8F55-4F2B-8962-(E-Mail Removed)...
>> > > > 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.
>> > > >
>> > >
>> > >
>> > >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cpu misread? Gordon J. Rattray Windows XP Hardware 9 30th Sep 2007 03:25 AM
NotSupportedException Type.GetType (String, Boolean, Boolean) jonfroehlich Microsoft Dot NET Compact Framework 1 20th Apr 2006 02:44 PM
Misread imported contacts displayed by category srudder@gmail.com Microsoft Outlook Discussion 1 20th Jan 2006 07:01 PM
No boolean object in VB.NET? How to check if a boolean has been explicitely defined then? Lucas Tam Microsoft VB .NET 10 12th Jun 2005 09:29 PM
HDD misread space Paul Windows XP Hardware 1 15th Aug 2003 12:50 AM


Features
 

Advertising
 

Newsgroups
 


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