+ Reply to Thread
Results 1 to 10 of 10

Select Case: Formatting the code properly

  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Select Case: Formatting the code properly

    I am adding shapes with text (msoShapeOval) to an image on a worksheet but I cant get the size of the "ShapeRange" to work dependant on the value assigned to "sTxtlen".
    I had msgbox's within each Case but none were triggered allthough using another msgbox to show the length of sTxtLen is correct prior to the Select Case.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Any hints, tips or examples are welcome.
    Last edited by Rick_Stanich; 02-09-2010 at 11:31 AM.
    Regards

    Rick
    Win10, Office 365

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Select Case: Formatting the code propperly

    Not quite sure I follow but in general terms:

    Please Login or Register  to view this content.

    ie the Case lines related to the initial Select Case value which in this case is a Long.

    EDIT:

    ...if (big if) the sizing is that "structured" you could perhaps dispense with the Select Case and use:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Select Case: Formatting the code propperly

    As an example:
    If I add a msgbox to each Case I can tell that the code is not evaluating as written because no msgbox is triggered.
    Please Login or Register  to view this content.
    The goal is to size the msoOvalShape to fit the value of sTxtLen (same as lngCount but as a string).
    If the length of sTxtLen is "1" then set a size and so on...as the value increases in length the shape increases by a set value.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Select Case: Formatting the code propperly

    Rick, I'm guessing you didn't get the point of my post...

    The Case tests should be based on the initial Select Case value... in your case this is Long ... ergo the Case tests should themselves be numerical tests

    Think of it like

    Please Login or Register  to view this content.
    each Case represents a test based on the value of lngX

    (per my earlier note using those values specified you don't really need the Select Case)

  5. #5
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Select Case: Formatting the code propperly

    (sTxtLen is a string and lngCount is a Long)
    I appreciate your help, but obviously I am not understanding something about Case's or the info you supplied.
    I thought setting "sTxtLen = lngCount" established a variable I can check the length of the value. If I check the length of lngCount always get "4" (might be numeric format such as "0000"?).
    Checking sTxtLen returns the length of the value.
    This IF statement works.
    Please Login or Register  to view this content.
    What lead me to a Case? I thought a Case statement would have a simpler format.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Select Case: Formatting the code propperly

    I think I'm guilty of misreading your code too...

    If you want to test based on the Len of the Long then modify the initial Select Case statement accordingly, ie:

    Please Login or Register  to view this content.

    or, using the earlier non-Select Case approach (viable given standardised increments):

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Select Case: Formatting the code propperly

    Quote Originally Posted by DonkeyOte View Post
    or, using the earlier non-Select Case approach (viable given standardised increments):

    Please Login or Register  to view this content.
    Now thats simplified! And works!
    Thank you for your assitance!
    Last edited by DonkeyOte; 02-09-2010 at 11:53 AM. Reason: trimmed quote to relevant parts

  8. #8
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Select Case: Formatting the code propperly

    The Select Case working:
    Please Login or Register  to view this content.

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Select Case: Formatting the code propperly

    Rick, point being:

    Please Login or Register  to view this content.

    isn't required

    The first line in your Select Case:

    Please Login or Register  to view this content.

    will result in a numeric value, the numeric value being the no. of chars in the string specified, on that basis it follows that:

    Please Login or Register  to view this content.

    works exactly the same way as your code but with obviously fewer operations ... as it is you're effectively duplicating the Len test (at least once - at most five times over).

    I hope I've explained it this time ?

  10. #10
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Select Case: Formatting the code propperly

    I got it now.
    I couldn't figure out what the beeping sound was, turns out, I just had to plug in the brain holder. Batteries were low.
    Last edited by DonkeyOte; 02-09-2010 at 11:51 AM. Reason: unnec. quote removed

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1