-
Oct 30th, 2007, 04:52 PM
#1
Thread Starter
Addicted Member
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.
-
Oct 30th, 2007, 04:54 PM
#2
Re: stop when value = ?
One way would be to replace the variable with a user defined Property and put validation code in the Property Let.
-
Oct 30th, 2007, 05:21 PM
#3
Re: stop when value = ?
Yes in the IDE, Use the Watch Expression...
-
Oct 31st, 2007, 03:23 AM
#4
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
-
Oct 31st, 2007, 01:23 PM
#5
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
-
Oct 31st, 2007, 03:20 PM
#6
Re: stop when value = ?
If you use the Watch Expression you don't have to remove anything before compiling.
-
Oct 31st, 2007, 03:40 PM
#7
Re: stop when value = ?
I'd listen to randem and go with the Watch expression
-
Oct 31st, 2007, 04:03 PM
#8
Thread Starter
Addicted Member
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.
-
Oct 31st, 2007, 04:23 PM
#9
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
-
Oct 31st, 2007, 04:56 PM
#10
Thread Starter
Addicted Member
Re: stop when value = ?
nothing that could corrupt the variable other than changing it constantly.
-
Oct 31st, 2007, 05:26 PM
#11
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
-
Nov 1st, 2007, 03:49 AM
#12
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
-
Nov 1st, 2007, 02:21 PM
#13
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|