Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm pretty much a newbie when it comes to programming. I have written
a program for my work which has been used for months and produces what it needs to and all that but I have a question... Whilst programming it I noticed a couple of things which I thought where unsual... One being that I had a line of code which used to 95% of the time, do what I wanted it to but the other 5% not. Now to fix it, all I did was tab the line of code further under the presvious line of code. So it went from this: code code code code code code code code to this code code code code code code code code The line didn't change. Only the position. Can someone explain this to me...the reason I ask is because I think I have a problem with my program but it doesn't happen that often but looks similar. It's funny...I always thought that because a computer runs on 1s and 0s that if it reads and acts on a line of instruction once one way, it will always read and act that way because it is *that* black and white... Cheers, Craig.... -- The Zero ST |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The code reads and executes one line at a time but does so in the order the
lines are written. So if you move one line to another position in a number of lines of code, the result could be radical. For instance, say you have one line that defines some variable, then a following line that uses that variable in a calculation or process. If you switch those 2 lines and run the code, you will get an error when the attempt is made to use a variable that hasn't yet been defined. And yes, right or wrong, the code will always do the same thing every time it runs. HTH Otto "Craig Coope" wrote in message ... I'm pretty much a newbie when it comes to programming. I have written a program for my work which has been used for months and produces what it needs to and all that but I have a question... Whilst programming it I noticed a couple of things which I thought where unsual... One being that I had a line of code which used to 95% of the time, do what I wanted it to but the other 5% not. Now to fix it, all I did was tab the line of code further under the presvious line of code. So it went from this: code code code code code code code code to this code code code code code code code code The line didn't change. Only the position. Can someone explain this to me...the reason I ask is because I think I have a problem with my program but it doesn't happen that often but looks similar. It's funny...I always thought that because a computer runs on 1s and 0s that if it reads and acts on a line of instruction once one way, it will always read and act that way because it is *that* black and white... Cheers, Craig.... -- The Zero ST |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Thu, 23 Aug 2007 18:46:05 -0400, "Otto Moehrbach"
wrote: The code reads and executes one line at a time but does so in the order the lines are written. So if you move one line to another position in a number of lines of code, the result could be radical. For instance, say you have one line that defines some variable, then a following line that uses that variable in a calculation or process. If you switch those 2 lines and run the code, you will get an error when the attempt is made to use a variable that hasn't yet been defined. And yes, right or wrong, the code will always do the same thing every time it runs. HTH Otto Thanks for your reply... I didn't mean change the position of the code as in put it before or after another line of code I simply meant keeping the code in the same order but as I had shown in my original post just "tabbed" (i.e added a blank space) at the start of the code so that the first letter of the code is nolonger directly below the first letter of the line directly above... Example If TextBox1 = "password" Then Me.Hide fs.nstate = 5 Else Me.Hide fs.nstate = 1 Module5.showMessage End If and..... If TextBox1 = "letmeout" Then Me.Hide fs.nstate = 5 Else Me.Hide fs.nstate = 1 Module5.showMessage End If That is what I mean. Looks like the code should act the same but it doesn't. I want to know why. -- The Zero ST |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Fri, 24 Aug 2007 00:10:49 +0100, Craig Coope
wrote: Example If TextBox1 = "password" Then Me.Hide fs.nstate = 5 Else Me.Hide fs.nstate = 1 Module5.showMessage End If and..... If TextBox1 = "letmeout" Then Me.Hide fs.nstate = 5 Else Me.Hide fs.nstate = 1 Module5.showMessage End If That is what I mean. Looks like the code should act the same but it doesn't. I want to know why. Sorry to repost but just to clarify. When I had the code with the tabbed space the code did work, just not all the time. (Usually it was the first button press that didn't work). After I moved the bottom part of the code to the left it works everytime... Am I crazy? -- The Zero ST |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Thu, 23 Aug 2007 18:46:05 -0400, "Otto Moehrbach"
code code code code code code code code to this code code code code code code code code Well maybe it is mine or your newsreader but it missed out the spaces I put in my original post! :o( and thus it may miss them out again in my other reply to you... So here goes... code code code code code code code code and code code code code (spaces here!) code code code code Hope that works... -- The Zero ST |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Could it be that you also changed the comparison?
Your 'If' went from "password" to "letmeout". -pb |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Thu, 23 Aug 2007 17:37:41 -0700, cubbybear3
wrote: Could it be that you also changed the comparison? Your 'If' went from "password" to "letmeout". -pb Oops...nope...that was my fault when I compiled the post...it was all exactly the same at the time... -- The Zero ST |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Clarification | Excel Discussion (Misc queries) | |||
Subtotal - Clarification | New Users to Excel | |||
clarification | Excel Programming | |||
clarification | Excel Programming | |||
Clarification please... | Excel Programming |