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

Can someone please explain to me what this line of code is doing. I have some idea, but would like to know exactly what it is doing. If you could break it down that would be great. Thanks. Mat

nChkNum = CInt(Mid$(ole.Name, Len("Checkbox") + 1))
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Explanation of code

Matt,

CInt converts a number held as a string into an integer.

Len returns the number of characters in a string or value.

Mid$ returns a subset of another string as a string. In
this case, the string in question is the Name property
of "ole" (which I assume is an ole Object variable.) Thus,
Mid("Peter",2,3) would return "ete".

The second argument in the Mid function determines the
point in the string at which the substring starts and this
is where the problem arises(if you are having a problem,
that is...)

Len("Checkbox") will always return 8, as you are
calculating the length of the string contained between the
inverted commas. If it is supposed to be testing a
variable, the correct form would be:
Len(Checkbox)
or Len(Checkbox.value) if it's an object.

If you're happy with it the way it is then:
CInt(Mid$(ole.Name, 9))
would be simpler!

Cheers, Pete

-----Original Message-----
Can someone please explain to me what this line of code

is doing. I have some idea, but would like to know
exactly what it is doing. If you could break it down that
would be great. Thanks. Matt

nChkNum = CInt(Mid$(ole.Name, Len("Checkbox") + 1))
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Explanation of code

Thanks Pete. So what your last comment is saying is that I can just say to start the substring at the 9th position and it will pick up everything from that point on or do I have to tell it how many characters to go from the starting point. The reason is I have control checkboxes, and I needed to take the numbers from the names of the checkboxes to do a loop that will only make a range of checkboxes visible. My range is from checkbox2-checkbox30. The main reason I wanted to understand what this does, is that I want to rename the cells that these checkboxes are in so that the cell w/ checkbox 2 will be renamed to "Box 2". Then write a loop that will check if checkbox2 value it true. If it is true, then I want to change the locked on "Box 2/cell" to true. Also, if there is text in "Box 2/cell", then I want to make checkbox2 visible to be false. This way they can either select the checkbox or type text in the cell, but not both. Any help would be great. Thanks. Matt
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Explanation of code

Matt,

the mid statement has three parts. Mid("Matt",2,1)

The first is the source string, the second the start
character for the result and the third how many characters
to return. If you omit the third argument, it will go up
to the end of te source string. For example:
Mid("Matt",2,1) returns "a", but

Mid("Matt",2) returns "att".

With regards to you checkboxes, are they in a userform and
how many are there in total? Has checkbox1 been deleted,
or is it just not part of the group you want to manipulate?

Pete

-----Original Message-----
Thanks Pete. So what your last comment is saying is that

I can just say to start the substring at the 9th position
and it will pick up everything from that point on or do I
have to tell it how many characters to go from the
starting point. The reason is I have control checkboxes,
and I needed to take the numbers from the names of the
checkboxes to do a loop that will only make a range of
checkboxes visible. My range is from checkbox2-
checkbox30. The main reason I wanted to understand what
this does, is that I want to rename the cells that these
checkboxes are in so that the cell w/ checkbox 2 will be
renamed to "Box 2". Then write a loop that will check if
checkbox2 value it true. If it is true, then I want to
change the locked on "Box 2/cell" to true. Also, if there
is text in "Box 2/cell", then I want to make checkbox2
visible to be false. This way they can either select the
checkbox or type text in the cell, but not both. Any help
would be great. Thanks. Matt
.

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
FORMULA EXPLANATION SSJ New Users to Excel 7 July 26th 07 07:03 PM
Explanation of when & how to use ( ) { } : ; , ! etc? Paul (Sydney Australia) New Users to Excel 4 May 2nd 07 01:54 AM
Foremula Explanation Prince Ali Charts and Charting in Excel 1 November 28th 06 07:44 PM
Comma explanation George Excel Worksheet Functions 3 December 13th 04 09:30 PM
Explanation of code marksuza Excel Programming 2 November 21st 03 11:45 AM


All times are GMT +1. The time now is 09:48 AM.

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

About Us

"It's about Microsoft Excel"