dcsimg
Results 1 to 13 of 13

Thread: stop when value = ?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    145

    stop when value = ?

    Is there a way to make the code stop when a variable goes say to -88000. I need to find out where it is going deep into the negatives and there are so many goto statements im lost in the forest. (im translating a government fortran program to vb (goto was the thing back then) and the translater program didnt think to remove them. How kind right?) So my value has a general range of 9600ish and then all of a sudden goes to -88000 and I cant find where it does this.

    Is there some kind of neat trick you can do to zoom to the code that makes a variable change past a certain number? The break points only work so well, b/c the variables switch names several times so im slowing tracking down how it changes to -88000. Any help would be incredibly appreciated.

  2. #2

  3. #3
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: stop when value = ?

    Yes in the IDE, Use the Watch Expression...

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,717

    Re: stop when value = ?

    if myvar > -500 then stop

    remember to remove before compiling

    or should that be <
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: stop when value = ?

    It should be <, as in
    If myvar < -500 Then Stop
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  6. #6
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: stop when value = ?

    If you use the Watch Expression you don't have to remove anything before compiling.

  7. #7

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    145

    Re: stop when value = ?

    great guys this is perfect. I added a watch to the var "cpr" but when it breaks the highlighted area is a var cv = cpd (cpd actually is the value that cpr is) but I want to see where cpr is changing not where the variable that changes cpr is changed.

    Also when I click on edit watch. The expression is like 20 spaces over from the start. Is that normal? It looks like this.

    Expression: t

    Another question is t is never shown to have a value but when i look in the variable window i can see it has a value of 671. Why is this?
    Last edited by Armageddon85; Oct 31st, 2007 at 04:08 PM.

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: stop when value = ?

    Are you doing any memory manipulation? Copying or moving data in memory? Or anything else that can corrupt a variable?
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    145

    Re: stop when value = ?

    nothing that could corrupt the variable other than changing it constantly.

  11. #11
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: stop when value = ?

    I think you're telling us that the computer is saying something like 1 > 2, and that can't happen. If memory isn't being corrupted, and you're stopping on cpr changing, and the computer stops on cpr not being changed, either VB or Windows (or your CPU) isn't working properly.

    What's the line immediately above cv = cpd?

    What are cv and cpd defined as?
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  12. #12
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,717

    Re: stop when value = ?

    variables that are not declared can sometimes change value for no obvious reason, make sure to declare all the variables you are using
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  13. #13
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: stop when value = ?

    Are you using Option Explicit in the top of your forms/modules/classes????
    If not then this could just be the tip of the problems to come...

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width