+ Reply to Thread
Results 1 to 55 of 55

VBA Developers Handbook, 2nd Edition. questions on procedures and functions

  1. #1
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    so im reading VBA Developer's Handbook, 2nd edition and i have a question about a function (why it's returning 0, when it should be greater than 0). see below:

    Please Login or Register  to view this content.
    and here is the procedure

    Please Login or Register  to view this content.
    Is there a problem with the function or how i'm implementing the procedure?
    Last edited by dmcgov; 03-25-2019 at 07:29 AM.

  2. #2
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Function returns 0 when it the test is run but it should be greater than 0

    there's nothing wrong, per se, aside the penultimate line in your Function... i.e. dhCountInCaseS

  3. #3
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Function returns 0 when it the test is run but it should be greater than 0

    thanks @xlent. my goof. appreciate you taking the time to debug this for me. now all working.

  4. #4
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Function returns 0 when it the test is run but it should be greater than 0

    so onto another issue with the following function:

    Please Login or Register  to view this content.
    no matter what i try, it always says "Constant expression required" even though it's optional. here is what i tried to use:

    Please Login or Register  to view this content.
    even if i add dhcDelimiters to the function, it still fails at the function. what am i implementing wrong?

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: Function returns 0 when it the test is run but it should be greater than 0

    You need to remove this:

    Please Login or Register  to view this content.
    Rory

  6. #6
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Function returns 0 when it the test is run but it should be greater than 0

    ya i had tried that solution but did remove it from the procedures. however when i debug the project, i still get the same error on the function, this line:

    Please Login or Register  to view this content.
    and it highlights dhcDelimiters.
    Attached Images Attached Images

  7. #7
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    The constant scope needs to be visible to the function - so either Public or if all the code is in the same module, at module level in that module.

  8. #8
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    yes i understand, but even if i comment out the code after the function, when i try to compile, it always says the same error in post #6, so the problem is that the function error's out. i have even copied the code directly from the book, but still get the same error. so what is wrong with the code in the function. that is where the error is. so one note, is that i put the const dhcDelimiters in the actual function, so compile works but when i run one of the procedures, it still goes back to the constant error. what is my limited brain not understanding?

  9. #9
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    Code module should start with:

    Please Login or Register  to view this content.
    Then:
    Please Login or Register  to view this content.
    and the function should be:

    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    sigh, im without words. i copied everything verbatim from your post. cant get rid of the constant error.

    here is two of my public procedure, neither work.

    Please Login or Register  to view this content.
    everything is in the same module (only have one). should i just move on?

    is maybe something wrong with my excel program? or is it just me (Probably). let me attach my workbook, and maybe you can take a peek at it, see if that's whats wrong?
    Attached Files Attached Files

  11. #11
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    Quote Originally Posted by dmcgov View Post
    sigh, im without words. i copied everything verbatim from your post.
    You really didn't.

    The Public Const line should appear once, at the top of the module, and nowhere else.

  12. #12
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    thanks again for sticking the out on me, i knew is was my mistake.

  13. #13
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    No worries - we all do it!

  14. #14
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    and that helped me solve a couple of other issues that weren't working as procedures. now i can cross off chapter 1. hopefully this makes me a better coder.

  15. #15
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    so on to the next chapter. i have this function, how to correctly write a procedure to test it. here's the function:

    Please Login or Register  to view this content.
    and there are the procedures that i have tried:

    Please Login or Register  to view this content.
    this generates an error
    then i tried this
    Please Login or Register  to view this content.
    that generates an error as well. finally i tried this:

    Please Login or Register  to view this content.
    that does not generate an error but does not output the average, it's just blank.

    what am i doing wrong?
    Last edited by dmcgov; 03-26-2019 at 08:22 AM. Reason: straightened out the [CODE] blocks

  16. #16
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    It's expecting an array, not three arguments, or a string, so:

    Please Login or Register  to view this content.

  17. #17
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    thanks, that will help me in several of the Array functions. appreciate the help. got two more that aren't working from chapter 2. will post them separately. then im done with the chapter and on to three.

  18. #18
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    Only 13 to go.

  19. #19
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    im learning at a fast pace, thanks for all your help. now onto the next function that is erroring out, i see why, but don't know how.

    Please Login or Register  to view this content.
    and here is the function:

    Please Login or Register  to view this content.
    is't erroring out on this line

    Please Login or Register  to view this content.
    when i check the locals window,i see that lngTotalOccur and lngLastOccur are 0, the varItem is 1 and lngCount is 0 (thats where the error is, can't have a negative number for varArray).

    did i make a typo or something (i have checked the code a couple of times but don't see the error). what is wrong with the code (my mistake most likely).
    Last edited by dmcgov; 03-26-2019 at 09:09 AM. Reason: added parenthesis

  20. #20
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    OP moves with fast pace through Functions.
    Last edited by bakerman2; 03-26-2019 at 09:30 AM.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  21. #21
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    No, I think there are actually two errors in that code (One at least is just typographical). It should be:

    Please Login or Register  to view this content.

  22. #22
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    thanks, i use notepad++ for some of my coding, just ran a compare. i see the two issues. thanks for pointing that out. one of those "cant see the forest for the tree's issue".

  23. #23
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    At least it wasn't your error.

  24. #24
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    so another question on the numbers chapter. this has to do with factorials and recursive factorials. if i run the following procedure, shouldn't they both be the same (or am i not understanding what recursive means?

    Please Login or Register  to view this content.


    the result of running this is:

    the factorial of 19 is 1.21645100408832E+17
    the factorial recursive of 19 is 19

    i did find a typo which i fixed so here is the recursive function:

    Please Login or Register  to view this content.
    what am i doing wrong?

  25. #25
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    I get the same result with both.

  26. #26
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    Quote Originally Posted by bakerman2 View Post
    OP moves with fast pace through Functions.
    well yup, basically i run through each chapter and the ones that don't work i add a "_nw" to. that way i can quickly find the ones that are "not working". by reading each chapter through the end, i can fix a lot of mistakes. but yes, i am cranking out the questions. really glad you guys are lending a hand. this will go a long way into making me a better coder.

  27. #27
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    Quote Originally Posted by rorya View Post
    I get the same result with both.
    sometimes i get hiccups with excel not working as expected, so let me load up my workbook to see if you are getting the same result as I am. if you run this and it works, it just means my version of excel (office 365) is to blame.
    Attached Files Attached Files

  28. #28
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    Yes, I get the same 1.21E17 value for both.

  29. #29
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    what version of excel are you using Rorya?

    btw, closing chapter 2, on to dates and times

  30. #30
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    2010 (32 bit)

  31. #31
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    Using XL2007 they are both the same. Also using Application.Fact(19) gives the same result.

  32. #32
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    quick question, does anyone have the CD from this book? looking to get the Holidays.xml or Holidays.mdb file.

  33. #33
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    so only two procedures are not working from chap 3. here is the first function:

    Please Login or Register  to view this content.
    and here is the procedure that doesn't work (prints 12:00:00 AM)

    Please Login or Register  to view this content.
    is the book wrong or did i make a typo?

  34. #34
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    thoughts anyone?

  35. #35
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    Here's the function signature:

    Please Login or Register  to view this content.
    And here's the assignment of the result:

    Please Login or Register  to view this content.
    See the problem?

    Option Explicit is your friend.
    Entia non sunt multiplicanda sine necessitate

  36. #36
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    This line
    Please Login or Register  to view this content.
    needs to be
    Please Login or Register  to view this content.

  37. #37
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    thanks, thought it was me (mistyping). so the other function that doesn't work is a doozy for me.

    the function thats tripping me up is below:

    Please Login or Register  to view this content.

    the procedure that i am running is:

    Please Login or Register  to view this content.
    it complains that "GetSystemDefaultLCID" and "GetLocalInfo" are not defined. from reading the text i understand that these are api calls. i googled the internet for both functions but came up empty (microsoft says they are depreciated i think). is there a way to declare the api function calls in the declaration section?

  38. #38
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    The two API calls are at the top of the DateTime.bas file:

    Please Login or Register  to view this content.
    I have attached the two files you mentioned.
    Attached Files Attached Files

  39. #39
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    thanks rorya for the zip, helped me to close chapter 3. just so you know i have the ebook, so don't have access to the CD. trying to find out if sybex still has that with the printed book. be so much easier if i could just copy.

    so finished with chapter 4 and 5, moving on to 6 "arrgh" = heavy topic. reading on classes from other excel sites. not for the faint of heart.

  40. #40
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    so i am having an issue with my new class module, getting a run time error 424, object required.

    here is my module code:

    Please Login or Register  to view this content.
    i get the error on the set cls_btnCode statement.

    here is my class module:

    Please Login or Register  to view this content.
    what am i doing wrong?

    it behaves correctly in that it shows the userform, lets me type, tracks the character count. when i press ok, it displays a msgbox which contains the correct text.

  41. #41
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    You need an Exit Sub before errhandler:

  42. #42
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    An On Error statement wouldn’t hurt either.

    I suspect the underlying issue is not specifying the form that contains the button.

  43. #43
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    Also, you don't want to be breaking encapsulation like that, you should be passing the UserForm object into the class. Oh, and don't use the default instances of user forms, ie. Never use NameOfUserForm.Show

    You should be using them properly:
    Please Login or Register  to view this content.
    The default instances won't always be what you expect them to be

  44. #44
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    thanks @shg and @rorya for that info. @kyle123, here is code that is working but how do i get the data from the code window into the userform that the button generator makes?

    here's the module code:

    Please Login or Register  to view this content.
    and here is the class module code:

    Please Login or Register  to view this content.
    and here is my userform code:

    Please Login or Register  to view this content.
    so i tried to put a msgbox in the module code to get the data from the code window but it failed on that line. how do i do that?

  45. #45
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    so nevermind, i got it working.

    i added this (finally worked) to the module and now i can get the info out to the module.

    Please Login or Register  to view this content.
    now the question is how to get that code into the userform that the button generates. but i have to wait to get home to get the file that does that. didn't update my dropbox.

  46. #46
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    I've got no idea what that code is supposed to be doing, it doens't seem to make a lot of sense unless you are trying to create multiple userforms (even then it wouldn't work). I don't understand why you are using a class for this, there doesn't seem to be any need?

    What do you want the code to do?

  47. #47
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    so the button generator generates multiple buttons. other than the spacing, i have that working. so now that the class module clsCode is working. i now need that code to 'attach' it to the buttons (buttons need to do something right?) but the file that i need to do this is at home. so the question will have to wait till i can get to my laptop. im sure once i pull this all together, it will make sense (at least i hope that it will). please be patient as this grasshopper is still learning the ropes

  48. #48
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    Are you still trying to do that IDE automation where you are writing code with code?

  49. #49
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    yes, isn't that the way im supposed to do it? i thought that my first approach was wrong (in that i did it all at design time).

  50. #50
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    I don't think you should do any of it at design time. I don't understand why you'd want to.

  51. #51
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    am i still doing it wrong?

  52. #52
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    It really depends why you want to do it. Why do you want to do any of it at design time? - What's the purpose of the project?

  53. #53
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    well at first, all i knew was to create it at design time (showing my lack of knowledge). then you and others said it's not the way to do it. hence writing code that makes code and the use of class modules. i thought that was the right way to do it. and since i didn't have the knowledge, i got the VBA book to learn more. now im on chapter 6 which goes into more detail about class modules. which is why i wrote the clsCode code to get the actual code for the button. do i still not understand the correct way to do this? and the purpose was to do this right (and not at design time, which i said was all that i knew at the time)

  54. #54
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    If you want to have a userform that you can add a dynamic number of buttons to that have similar behaviour, then do it all at runtime:

    Module:
    Please Login or Register  to view this content.
    Userform:
    Please Login or Register  to view this content.
    Class:
    Please Login or Register  to view this content.

  55. #55
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: VBA Developers Handbook, 2nd Edition. questions on procedures and functions

    ahh, that is it very helpful. can't wait to get home to do this. thanks for hanging in there.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Which test is best for abnormal returns?
    By WASIM_PAK in forum Excel General
    Replies: 0
    Last Post: 08-27-2015, 11:39 AM
  2. Replies: 1
    Last Post: 08-10-2015, 10:30 AM
  3. Replies: 4
    Last Post: 08-07-2013, 11:29 AM
  4. return a value for a greater than less than logic test
    By azruss in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-03-2013, 12:50 PM
  5. Replies: 5
    Last Post: 12-09-2012, 11:04 PM
  6. WorksheetFunction.Sum returns 0 for array of elements whose sum is greater than 0
    By RowanB in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-12-2012, 06:15 AM
  7. Change Test Color If Value is Greater Than Another
    By BluTalon in forum Excel General
    Replies: 8
    Last Post: 11-07-2008, 10:24 AM

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