Consulting

Results 1 to 17 of 17

Thread: Solved: Debugging Immediate Window Question

  1. #1

    Solved: Debugging Immediate Window Question

    In this article: http://pubs.logicalexpressions.com/p...cle.asp?ID=410
    there is a statment I don't understand what the author is driving at;
    The Immediate window can also accept and format results in fixed width characters for a result set. Using Debug.Print to force the output to the Immediate window, you can force a wide range of variable states to Debug and format the results to present some usable information in the Immediate window.
    Could someone offer an example for me to try?
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Basically, he just means that most things (anything?) that you can do in a code statement, you can do in a Debug.Print. For example, you can format a date string, concatenate variables/variables and text, etc.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    ok... got it thanks
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

  4. #4
    Why is this expression a type mismatch?
    inf = Format(Date, "dddd, mmm d yyyy")

    [vba]
    Sub I_Is_For_Immediate()
    Dim I As Integer, inf As Date
    inf = Format(Date, "dddd, mmm d yyyy")
    For I = 0 To 10
    Debug.Print "I = " & I
    Debug.Print inf
    Next I
    End Sub
    [/vba]

    And the same here?

    [VBA]
    Sub I_Is_For_Immediate()
    Dim I As Integer, inf As Date
    inf = Format(Date, "long date")
    For I = 0 To 10
    Debug.Print "I = " & I
    Debug.Print inf
    Next I
    End Sub
    [/VBA]
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Because you have declared inf as type Date, Format returns a string.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Thanks again Bob,
    I am trying to get the value 23 to display as a string to 23%.
    I have been hunting around for this for a good while now. I found a Formatpercent function, but trying to grasp the string concept...
    Would you help on this one?
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

  7. #7
    For example:
    MyStr = Format(5, "0.00%") ' Returns "500.00%".
    Why does this return 500.00% when the value is only a single digit number and the "0.00" appears the same showing a single digit to the left of the decimal?
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

  8. #8
    I was able to get this to work...
    nmbr = Format(0.23, "0.00%")
    and I can see why... but I don't have any real foundation of how number formats are supposed to treat numbers...
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Because 5 is the equivalent of 5 times, which is 500%. A percentage is the number of times of something, say 20% of 1 dollar is one fifth of a dollar, or 0.2.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  10. #10
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Doug

    It returned the decimal bit because you told it to.
    [vba]
    nmbr = Format(5/100, "0%")
    [/vba]
    Or
    [vba]
    nmbr = 5 &"%"&
    [/vba]

  11. #11
    I see it now from the last two posts from Bob and Norie,

    So in this case:
    MyStr = Format(5, "0.00%") ' Returns "500.00%".

    This is equal to 5 * 100% : 0.00 is 100% of the number
    where if I wanted the percentage, I have to represent this in the number, not in the format.
    Format(.23, "0%") or Format(23/100, "0%")

    thanks...
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

  12. #12
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Doug

    Percentages are really numbers.

    1=100%
    0.1=10%
    0.3=30%
    etc

  13. #13
    Norie,
    What does that mean. Did you intrepret my posts as that I don't think percentages are not numbers, or "real" numbers?
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

  14. #14
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Doug

    No offense meant, I just thought that might give you a clearer idea of how Excel regards percentages.

  15. #15
    Norie,
    No offense taken whatsoever, and in no way meant it to imply it as such. I only asked to ensure the accuracy of my post. The initial reason for the post was and still is to better understand and use the builtin debugging tools.
    It could have been anything, but I also want to learn how the number formats, custom formats work so it was by chance this example was derived.
    Btw: You and me are well beyond that point... your assistance is always appreciated.
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

  16. #16
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Doug

    The best place to learn about formatting is probably the Help file.

    Not the VBA Help file, the Excel Help file.

  17. #17
    Yep... been looking there.... just not fast on the upswing.... I unfortunately only tend to really grasp things once I have used them and get comfortable....
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •