Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Clarification

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Clarification

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Clarification

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Clarification

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Clarification

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Clarification

Could it be that you also changed the comparison?
Your 'If' went from "password" to "letmeout".
-pb

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Clarification

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clarification pmayne181 Excel Discussion (Misc queries) 1 December 2nd 08 12:56 PM
Subtotal - Clarification DumbCluck New Users to Excel 1 December 10th 07 09:27 PM
clarification Michael Joe Excel Programming 3 August 13th 04 09:49 PM
clarification Michael Joe Excel Programming 0 August 13th 04 09:18 PM
Clarification please... JMay Excel Programming 9 April 24th 04 05:55 PM


All times are GMT +1. The time now is 12:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"