Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Newbie needs help with VBA Greek

  Asked By: Kelley    Date: Sep 25    Category: MS Office    Views: 829
  

This object oriented stuff is, strangely, starting to make
sense. (coming from a conventional programming background)

Have read the Mark Thorp Tech Trax tutorials and they have
cleared up several things. Greg Chapman's Debugging article is
helpful too. However, in general, I can't get used to the way
things are explained when it comes to VB. I see examples, but not
basic explanations.
Help seems pretty malodorous as well. I am used to
a "programmers reference" document which gives the commands and
explains the operands.

My questions
1- For:
Debug.Assert BoolVar

Help says "Conditionally suspends execution at the line on which the
method appears."

Conditionally ? What condition? What is the BoolVar for?

It appears, from Greg's code, but not the obtuse Help code, that
execution stops (Debug is asserted) when BoolVar is false, but it
doesn't say that. Is this correct? Sure seems a strange default to
pass a test when argument is _false_.

Shouldn't Help say: "When BoolVar (or argument) is false, suspends
execution at the line on which the method appears."

Greg's code:
Sub TestingImmediateAssert()
Dim boolAssertion
boolAssertion = True

For I = 0 To 10
If I > 5 Then
boolAssertion = False
End If
Debug.Assert boolAssertion
Next I

End Sub

2- Hovering over "Debug." Shows only two possible choices (methods),
so that's all that Debug can do (print and halt-on-false), right?

3- Lots more in time….

BTW, I wasn't using Msg Boxes, I just put things into a sheet cell.
P.S. I'm using Excel to control my ham radio via the serial port. I
found a sheet on the web that did it and am modifying it / learning.

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Randy Warren     Answered On: Sep 25

Firstly, yes debug  only has Assert and Print. Considering what debug
is to be used for I think it covers all uses.

Obviously the Print will output any information you think is relevant
to trackdown bugs or odd behaviuor. You can also use the watch window.

The Debug.Assert BoolVar
BoolVar is a variable or result from a conditional test.
So you could also use either the following to go into debug mode when i=6

For i = 0 To 10
Debug.Assert i <= 5
Next i

For i = 0 To 10
Debug.Assert Not(i > 5)
Next i

A guess as to why FALSE should be used to start debug is that
variables that are not dim'd or currently have a value would cause the
debug to start. This is usually a big clue as to why things  are not
working as expected.

Use the contents tab of the vba help  to get a programmers reference
style, for properties, methods, keywords, functions.

It good to see you have an interest in debug. It's usually the last
thing new coders worry about

 
Answer #2    Answered By: Frederick Greene     Answered On: Sep 25

The reason for the false  value triggering Debug, is that the condition
specified is the normal behaviour you want. Anything else means time to
debug.



The Debug.Assert statement should be read  as though it says "If a condition
arises where the stated condition  is not true then drop into debug"

 
Answer #3    Answered By: Kelly Bell     Answered On: Sep 25

"variables that are not dim'd " [are assigned a false  value -
implied/understood]. Got it!


> or currently have a value [ of false?] would cause the
debug  to start.

Typo?

The implication is that bool Vars are "all" used to
indicate "trouble" when in the FALSE state. Not one of my base
assumptions.


> Use the contents tab of the vba help  to get a programmers reference
> style, for properties, methods, keywords, functions.

Sounds like another good thing to know.


> It good to see you have an interest in debug. It's usually the last
> thing new coders worry about :)

Well... I wouldn't say I'm a new coder, just new to VB. I developed
my own laser light show system in the mid 80's on the, ahemm...,
Radio Shack Color Computer - 6809. Basic OS and assembler display
processor...counting processor cycles and all...real time rotates all
at .98 MHz. ! !
It can be a curse going through all the working code  to remove the
file bloat caused by the debugging  print statements, but my mantra is
that test  and comments (and the algorithim phase - I use flowcharts)
take >> time than writing (actually "entering") the code....

 
Answer #4    Answered By: Angel Harris     Answered On: Sep 25

From the "Thanks...but" Department...
> ...snip...
> Use the contents tab of the vba help  to get a programmers reference
> style, for properties, methods, keywords, functions.

I went back and looked, but it's the same info I saw by doing my
search for the debug  info. Sorry, but perhaps you didn't catch my
remark:
> > Help seems pretty malodorous as well. ...
a.k.a. stinks as usual.

For Debug.Assert BoolVar, the Help says:
> > "Conditionally suspends execution  ...

> > Conditionally ? What condition? What is the BoolVar for?

Then I speculated:
> > Shouldn't Help say: "When BoolVar (or argument)
> > is FALSE, suspends execution ...

Since I'm not formally schooled in the ways of the Borg (said semi-
affectionately), I wouldn't know that things  happen on a FALSE
condition when they are done "conditinally". At least that is the
implication. I am used to naming things by what happens when the
variable / signal is high or asserted.

Halt -> when high or asserted then STOP
Run -> when high or asserted then GO
Run = *Halt , or HALT bar, or NOT HALT if you prefer. SO I
expected the Debug thingy to be "asserted" (halt execution) when
sumptin' is TRUE.

 
Answer #5    Answered By: Cheri Garcia     Answered On: Sep 25

I should have also said that using the contents tab is a good
suggestion as well because, it is laid out in a more objective
format.

 
Didn't find what you were looking for? Find more on Newbie needs help with VBA Greek Or get search suggestion and latest updates.




Tagged: