PC Review


Reply
Thread Tools Rate Thread

Adding a watch expression in VB

 
 
Mahadevan Swamy
Guest
Posts: n/a
 
      31st May 2007
Hi,

I am using VB and excel and I would like to know how to add a watch to
an expression in VB for some lines of code. When I select a value in
excel and add a watch on a variable, I get Value: <Out of Context>.
Could somebody please explain how to add a watch expression properly
when i select a value in excel. Thanks in advance.

Swamy

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      31st May 2007
the values will be out of contextt until the macro is run. Put a break point
(F9) where the variables are used and then run until break point is reached.
The look at the watch.

"Mahadevan Swamy" wrote:

> Hi,
>
> I am using VB and excel and I would like to know how to add a watch to
> an expression in VB for some lines of code. When I select a value in
> excel and add a watch on a variable, I get Value: <Out of Context>.
> Could somebody please explain how to add a watch expression properly
> when i select a value in excel. Thanks in advance.
>
> Swamy
>
>

 
Reply With Quote
 
Mahadevan Swamy
Guest
Posts: n/a
 
      31st May 2007
All the VB codes are written in a module and I don't know how to
execute this module. When I try to press Run button, I get to run some
other macro but not this module. In a module I have different
functions and I want to execute those functions. Is there a way to
do that?

Thanks
Swamy


On May 31, 11:48 am, Joel <J...@discussions.microsoft.com> wrote:
> the values will be out of contextt until the macro is run. Put a break point
> (F9) where the variables are used and then run until break point is reached.
> The look at the watch.
>
> "Mahadevan Swamy" wrote:
> > Hi,

>
> > I am using VB and excel and I would like to know how to add a watch to
> > an expression in VB for some lines of code. When I select a value in
> > excel and add a watch on a variable, I get Value: <Out of Context>.
> > Could somebody please explain how to add a watch expression properly
> > when i select a value in excel. Thanks in advance.

>
> > Swamy



 
Reply With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      31st May 2007
Left Click on the subroutine (any place) then start macro F5- Run F8-Step

"Mahadevan Swamy" wrote:

> All the VB codes are written in a module and I don't know how to
> execute this module. When I try to press Run button, I get to run some
> other macro but not this module. In a module I have different
> functions and I want to execute those functions. Is there a way to
> do that?
>
> Thanks
> Swamy
>
>
> On May 31, 11:48 am, Joel <J...@discussions.microsoft.com> wrote:
> > the values will be out of contextt until the macro is run. Put a break point
> > (F9) where the variables are used and then run until break point is reached.
> > The look at the watch.
> >
> > "Mahadevan Swamy" wrote:
> > > Hi,

> >
> > > I am using VB and excel and I would like to know how to add a watch to
> > > an expression in VB for some lines of code. When I select a value in
> > > excel and add a watch on a variable, I get Value: <Out of Context>.
> > > Could somebody please explain how to add a watch expression properly
> > > when i select a value in excel. Thanks in advance.

> >
> > > Swamy

>
>
>

 
Reply With Quote
 
Mahadevan Swamy
Guest
Posts: n/a
 
      1st Jun 2007
Is there a way to evaluate the results of IF, OR, AND statements to
see whether the result comes out to be True or False?

Also when I assign a variable to a formula and when I debug the code,
the variable comes out to be Empty. What's wrong?

Eg. Beta = Atn(ShapeRadius / (Sqr(ShapeX ^ 2 + ShapeY ^ 2))) * (180 /
PI)

Value of Beta: False?

Can you please clarify

Thanks



On May 31, 2:28 pm, Joel <J...@discussions.microsoft.com> wrote:
> Left Click on the subroutine (any place) then start macro F5- Run F8-Step
>
> "Mahadevan Swamy" wrote:
> > All the VB codes are written in a module and I don't know how to
> > execute this module. When I try to press Run button, I get to run some
> > other macro but not this module. In a module I have different
> > functions and I want to execute those functions. Is there a way to
> > do that?

>
> > Thanks
> > Swamy

>
> > On May 31, 11:48 am, Joel <J...@discussions.microsoft.com> wrote:
> > > the values will be out of contextt until the macro is run. Put a break point
> > > (F9) where the variables are used and then run until break point is reached.
> > > The look at the watch.

>
> > > "Mahadevan Swamy" wrote:
> > > > Hi,

>
> > > > I am using VB and excel and I would like to know how to add a watch to
> > > > an expression in VB for some lines of code. When I select a value in
> > > > excel and add a watch on a variable, I get Value: <Out of Context>.
> > > > Could somebody please explain how to add a watch expression properly
> > > > when i select a value in excel. Thanks in advance.

>
> > > > Swamy



 
Reply With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      1st Jun 2007
the value of PI doesn't have a value try this
WorksheetFunction.Pi()

You can add to the watch formulas such as ShapeX ^ 2 + ShapeY ^ 2
wqatch items can be more than just one variable.

False is defined as zero and true is any value that is not zero. If you
don't havve you variables declared whan you get a value of zero VBA doesn't
know if zero means false or the number zero.

"Mahadevan Swamy" wrote:

> Is there a way to evaluate the results of IF, OR, AND statements to
> see whether the result comes out to be True or False?
>
> Also when I assign a variable to a formula and when I debug the code,
> the variable comes out to be Empty. What's wrong?
>
> Eg. Beta = Atn(ShapeRadius / (Sqr(ShapeX ^ 2 + ShapeY ^ 2))) * (180 /
> PI)
>
> Value of Beta: False?
>
> Can you please clarify
>
> Thanks
>
>
>
> On May 31, 2:28 pm, Joel <J...@discussions.microsoft.com> wrote:
> > Left Click on the subroutine (any place) then start macro F5- Run F8-Step
> >
> > "Mahadevan Swamy" wrote:
> > > All the VB codes are written in a module and I don't know how to
> > > execute this module. When I try to press Run button, I get to run some
> > > other macro but not this module. In a module I have different
> > > functions and I want to execute those functions. Is there a way to
> > > do that?

> >
> > > Thanks
> > > Swamy

> >
> > > On May 31, 11:48 am, Joel <J...@discussions.microsoft.com> wrote:
> > > > the values will be out of contextt until the macro is run. Put a break point
> > > > (F9) where the variables are used and then run until break point is reached.
> > > > The look at the watch.

> >
> > > > "Mahadevan Swamy" wrote:
> > > > > Hi,

> >
> > > > > I am using VB and excel and I would like to know how to add a watch to
> > > > > an expression in VB for some lines of code. When I select a value in
> > > > > excel and add a watch on a variable, I get Value: <Out of Context>.
> > > > > Could somebody please explain how to add a watch expression properly
> > > > > when i select a value in excel. Thanks in advance.

> >
> > > > > Swamy

>
>
>

 
Reply With Quote
 
Mahadevan Swamy
Guest
Posts: n/a
 
      1st Jun 2007
I defined PI at the very beginning of the program by saying Const PI =
3.14159265358979.
What is the difference between WorksheetFunction.Pi() and const PI? If
I were to convert to degrees, and using worksheetfunction.Pi(), should
i multiply by 180/PI or 180/PI()?

I have all my variables declared and linked to excel but it is still
not clear why I am getting Empty value when i place my cursor over a
variable?


On Jun 1, 10:18 am, Joel <J...@discussions.microsoft.com> wrote:
> the value of PI doesn't have a value try this
> WorksheetFunction.Pi()
>
> You can add to the watch formulas such as ShapeX ^ 2 + ShapeY ^ 2
> wqatch items can be more than just one variable.
>
> False is defined as zero and true is any value that is not zero. If you
> don't havve you variables declared whan you get a value of zero VBA doesn't
> know if zero means false or the number zero.
>
> "Mahadevan Swamy" wrote:
> > Is there a way to evaluate the results of IF, OR, AND statements to
> > see whether the result comes out to be True or False?

>
> > Also when I assign a variable to a formula and when I debug the code,
> > the variable comes out to be Empty. What's wrong?

>
> > Eg. Beta = Atn(ShapeRadius / (Sqr(ShapeX ^ 2 + ShapeY ^ 2))) * (180 /
> > PI)

>
> > Value of Beta: False?

>
> > Can you please clarify

>
> > Thanks

>
> > On May 31, 2:28 pm, Joel <J...@discussions.microsoft.com> wrote:
> > > Left Click on the subroutine (any place) then start macro F5- Run F8-Step

>
> > > "Mahadevan Swamy" wrote:
> > > > All the VB codes are written in a module and I don't know how to
> > > > execute this module. When I try to press Run button, I get to run some
> > > > other macro but not this module. In a module I have different
> > > > functions and I want to execute those functions. Is there a way to
> > > > do that?

>
> > > > Thanks
> > > > Swamy

>
> > > > On May 31, 11:48 am, Joel <J...@discussions.microsoft.com> wrote:
> > > > > the values will be out of contextt until the macro is run. Put a break point
> > > > > (F9) where the variables are used and then run until break point is reached.
> > > > > The look at the watch.

>
> > > > > "Mahadevan Swamy" wrote:
> > > > > > Hi,

>
> > > > > > I am using VB and excel and I would like to know how to add a watch to
> > > > > > an expression in VB for some lines of code. When I select a value in
> > > > > > excel and add a watch on a variable, I get Value: <Out of Context>.
> > > > > > Could somebody please explain how to add a watch expression properly
> > > > > > when i select a value in excel. Thanks in advance.

>
> > > > > > Swamy



 
Reply With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      1st Jun 2007
You may need to change 180 to 180# to make it a float value.

I sometimes need to break sttatements into pieces to debug problem

a = Sqr(ShapeX ^ 2 + ShapeY ^ 2)
b = ShapeRadius/a
c = Atn(a/b)
d = 180 /PI
e = c * d

"Mahadevan Swamy" wrote:

> I defined PI at the very beginning of the program by saying Const PI =
> 3.14159265358979.
> What is the difference between WorksheetFunction.Pi() and const PI? If
> I were to convert to degrees, and using worksheetfunction.Pi(), should
> i multiply by 180/PI or 180/PI()?
>
> I have all my variables declared and linked to excel but it is still
> not clear why I am getting Empty value when i place my cursor over a
> variable?
>
>
> On Jun 1, 10:18 am, Joel <J...@discussions.microsoft.com> wrote:
> > the value of PI doesn't have a value try this
> > WorksheetFunction.Pi()
> >
> > You can add to the watch formulas such as ShapeX ^ 2 + ShapeY ^ 2
> > wqatch items can be more than just one variable.
> >
> > False is defined as zero and true is any value that is not zero. If you
> > don't havve you variables declared whan you get a value of zero VBA doesn't
> > know if zero means false or the number zero.
> >
> > "Mahadevan Swamy" wrote:
> > > Is there a way to evaluate the results of IF, OR, AND statements to
> > > see whether the result comes out to be True or False?

> >
> > > Also when I assign a variable to a formula and when I debug the code,
> > > the variable comes out to be Empty. What's wrong?

> >
> > > Eg. Beta = Atn(ShapeRadius / (Sqr(ShapeX ^ 2 + ShapeY ^ 2))) * (180 /
> > > PI)

> >
> > > Value of Beta: False?

> >
> > > Can you please clarify

> >
> > > Thanks

> >
> > > On May 31, 2:28 pm, Joel <J...@discussions.microsoft.com> wrote:
> > > > Left Click on the subroutine (any place) then start macro F5- Run F8-Step

> >
> > > > "Mahadevan Swamy" wrote:
> > > > > All the VB codes are written in a module and I don't know how to
> > > > > execute this module. When I try to press Run button, I get to run some
> > > > > other macro but not this module. In a module I have different
> > > > > functions and I want to execute those functions. Is there a way to
> > > > > do that?

> >
> > > > > Thanks
> > > > > Swamy

> >
> > > > > On May 31, 11:48 am, Joel <J...@discussions.microsoft.com> wrote:
> > > > > > the values will be out of contextt until the macro is run. Put a break point
> > > > > > (F9) where the variables are used and then run until break point is reached.
> > > > > > The look at the watch.

> >
> > > > > > "Mahadevan Swamy" wrote:
> > > > > > > Hi,

> >
> > > > > > > I am using VB and excel and I would like to know how to add a watch to
> > > > > > > an expression in VB for some lines of code. When I select a value in
> > > > > > > excel and add a watch on a variable, I get Value: <Out of Context>.
> > > > > > > Could somebody please explain how to add a watch expression properly
> > > > > > > when i select a value in excel. Thanks in advance.

> >
> > > > > > > Swamy

>
>
>

 
Reply With Quote
 
Mahadevan Swamy
Guest
Posts: n/a
 
      1st Jun 2007
How do i make values very precise to 5 decimal digits in VB.

for eg. The value i got for this formula SensorDistance =
Sqr(((SensorX - ShapeX) ^ 2) + ((SensorY - ShapeY) ^ 2)) is
0.32927527997103 and for another variable I got ShapeRadius = 0.3295.
I would like to make the results from the formula very precise to 5
decimal digits. How do I do that?






On Jun 1, 11:05 am, Joel <J...@discussions.microsoft.com> wrote:
> You may need to change 180 to 180# to make it a float value.
>
> I sometimes need to break sttatements into pieces to debug problem
>
> a = Sqr(ShapeX ^ 2 + ShapeY ^ 2)
> b = ShapeRadius/a
> c = Atn(a/b)
> d = 180 /PI
> e = c * d
>
> "Mahadevan Swamy" wrote:
> > I defined PI at the very beginning of the program by saying Const PI =
> > 3.14159265358979.
> > What is the difference between WorksheetFunction.Pi() and const PI? If
> > I were to convert to degrees, and using worksheetfunction.Pi(), should
> > i multiply by 180/PI or 180/PI()?

>
> > I have all my variables declared and linked to excel but it is still
> > not clear why I am getting Empty value when i place my cursor over a
> > variable?

>
> > On Jun 1, 10:18 am, Joel <J...@discussions.microsoft.com> wrote:
> > > the value of PI doesn't have a value try this
> > > WorksheetFunction.Pi()

>
> > > You can add to the watch formulas such as ShapeX ^ 2 + ShapeY ^ 2
> > > wqatch items can be more than just one variable.

>
> > > False is defined as zero and true is any value that is not zero. If you
> > > don't havve you variables declared whan you get a value of zero VBA doesn't
> > > know if zero means false or the number zero.

>
> > > "Mahadevan Swamy" wrote:
> > > > Is there a way to evaluate the results of IF, OR, AND statements to
> > > > see whether the result comes out to be True or False?

>
> > > > Also when I assign a variable to a formula and when I debug the code,
> > > > the variable comes out to be Empty. What's wrong?

>
> > > > Eg. Beta = Atn(ShapeRadius / (Sqr(ShapeX ^ 2 + ShapeY ^ 2))) * (180 /
> > > > PI)

>
> > > > Value of Beta: False?

>
> > > > Can you please clarify

>
> > > > Thanks

>
> > > > On May 31, 2:28 pm, Joel <J...@discussions.microsoft.com> wrote:
> > > > > Left Click on the subroutine (any place) then start macro F5- Run F8-Step

>
> > > > > "Mahadevan Swamy" wrote:
> > > > > > All the VB codes are written in a module and I don't know how to
> > > > > > execute this module. When I try to press Run button, I get to run some
> > > > > > other macro but not this module. In a module I have different
> > > > > > functions and I want to execute those functions. Is there a way to
> > > > > > do that?

>
> > > > > > Thanks
> > > > > > Swamy

>
> > > > > > On May 31, 11:48 am, Joel <J...@discussions.microsoft.com> wrote:
> > > > > > > the values will be out of contextt until the macro is run. Put a break point
> > > > > > > (F9) where the variables are used and then run until break point is reached.
> > > > > > > The look at the watch.

>
> > > > > > > "Mahadevan Swamy" wrote:
> > > > > > > > Hi,

>
> > > > > > > > I am using VB and excel and I would like to know how to add a watch to
> > > > > > > > an expression in VB for some lines of code. When I select a value in
> > > > > > > > excel and add a watch on a variable, I get Value: <Out of Context>.
> > > > > > > > Could somebody please explain how to add a watch expression properly
> > > > > > > > when i select a value in excel. Thanks in advance.

>
> > > > > > > > Swamy



 
Reply With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      1st Jun 2007
declare variables double instead of single.

dim shapex as double

"Mahadevan Swamy" wrote:

> How do i make values very precise to 5 decimal digits in VB.
>
> for eg. The value i got for this formula SensorDistance =
> Sqr(((SensorX - ShapeX) ^ 2) + ((SensorY - ShapeY) ^ 2)) is
> 0.32927527997103 and for another variable I got ShapeRadius = 0.3295.
> I would like to make the results from the formula very precise to 5
> decimal digits. How do I do that?
>
>
>
>
>
>
> On Jun 1, 11:05 am, Joel <J...@discussions.microsoft.com> wrote:
> > You may need to change 180 to 180# to make it a float value.
> >
> > I sometimes need to break sttatements into pieces to debug problem
> >
> > a = Sqr(ShapeX ^ 2 + ShapeY ^ 2)
> > b = ShapeRadius/a
> > c = Atn(a/b)
> > d = 180 /PI
> > e = c * d
> >
> > "Mahadevan Swamy" wrote:
> > > I defined PI at the very beginning of the program by saying Const PI =
> > > 3.14159265358979.
> > > What is the difference between WorksheetFunction.Pi() and const PI? If
> > > I were to convert to degrees, and using worksheetfunction.Pi(), should
> > > i multiply by 180/PI or 180/PI()?

> >
> > > I have all my variables declared and linked to excel but it is still
> > > not clear why I am getting Empty value when i place my cursor over a
> > > variable?

> >
> > > On Jun 1, 10:18 am, Joel <J...@discussions.microsoft.com> wrote:
> > > > the value of PI doesn't have a value try this
> > > > WorksheetFunction.Pi()

> >
> > > > You can add to the watch formulas such as ShapeX ^ 2 + ShapeY ^ 2
> > > > wqatch items can be more than just one variable.

> >
> > > > False is defined as zero and true is any value that is not zero. If you
> > > > don't havve you variables declared whan you get a value of zero VBA doesn't
> > > > know if zero means false or the number zero.

> >
> > > > "Mahadevan Swamy" wrote:
> > > > > Is there a way to evaluate the results of IF, OR, AND statements to
> > > > > see whether the result comes out to be True or False?

> >
> > > > > Also when I assign a variable to a formula and when I debug the code,
> > > > > the variable comes out to be Empty. What's wrong?

> >
> > > > > Eg. Beta = Atn(ShapeRadius / (Sqr(ShapeX ^ 2 + ShapeY ^ 2))) * (180 /
> > > > > PI)

> >
> > > > > Value of Beta: False?

> >
> > > > > Can you please clarify

> >
> > > > > Thanks

> >
> > > > > On May 31, 2:28 pm, Joel <J...@discussions.microsoft.com> wrote:
> > > > > > Left Click on the subroutine (any place) then start macro F5- Run F8-Step

> >
> > > > > > "Mahadevan Swamy" wrote:
> > > > > > > All the VB codes are written in a module and I don't know how to
> > > > > > > execute this module. When I try to press Run button, I get to run some
> > > > > > > other macro but not this module. In a module I have different
> > > > > > > functions and I want to execute those functions. Is there a way to
> > > > > > > do that?

> >
> > > > > > > Thanks
> > > > > > > Swamy

> >
> > > > > > > On May 31, 11:48 am, Joel <J...@discussions.microsoft.com> wrote:
> > > > > > > > the values will be out of contextt until the macro is run. Put a break point
> > > > > > > > (F9) where the variables are used and then run until break point is reached.
> > > > > > > > The look at the watch.

> >
> > > > > > > > "Mahadevan Swamy" wrote:
> > > > > > > > > Hi,

> >
> > > > > > > > > I am using VB and excel and I would like to know how to add a watch to
> > > > > > > > > an expression in VB for some lines of code. When I select a value in
> > > > > > > > > excel and add a watch on a variable, I get Value: <Out of Context>.
> > > > > > > > > Could somebody please explain how to add a watch expression properly
> > > > > > > > > when i select a value in excel. Thanks in advance.

> >
> > > > > > > > > Swamy

>
>
>

 
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
cheap Gucci watch JACOB watch Louls Vuitton watch ROLEX watch TISSOTwatch Tudor watch yuwenwu007@gmail.com Microsoft ASP .NET 0 23rd Jan 2008 06:31 PM
Unable to see value in Watch. Message: "Cannot evaluate expression because the code of the current m Ajit Goel Microsoft ASP .NET 0 16th Apr 2007 09:59 PM
Unable to see value in Watch. Message: "Cannot evaluate expression because the code of the current m Ajit Goel Microsoft ASP .NET 0 16th Apr 2007 09:57 PM
Invalid watch expression davegb Microsoft Excel Programming 4 29th Jun 2005 02:32 PM


Features
 

Advertising
 

Newsgroups
 


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