+ Reply to Thread
Results 1 to 9 of 9

code consolidation

  1. #1
    Banned User!
    Join Date
    01-17-2021
    Location
    Omaha, NE
    MS-Off Ver
    office 2016
    Posts
    211

    code consolidation

    i write best AI detection i know how. i'm detecting automated messages coming from certain people. i havve following functions behind outlook session
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    is there better way to do this with less code?

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: code consolidation

    What is your concern? The code is fairly compact and efficient. Trying to make it smaller would probably make is less readable but no more efficient.

    I would make one change but you wouldn't notice any practical difference in how fast it runs. Using a function to return a static string is terribly inefficient. Just move the string up into the calling function and delete function keywords_bad.
    Please Login or Register  to view this content.
    Also I note that it is ironic that you are responding to an automated message to say that you don't respond to automated messages. Why are you even sending a response?
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Banned User!
    Join Date
    01-17-2021
    Location
    Omaha, NE
    MS-Off Ver
    office 2016
    Posts
    211

    Re: code consolidation

    reason i dont want to use constant and use function instead is because the constant takes memory and sits unused when the session is running. function does not use anything until called. what i notice so far is that outlook's code, any code, is bad and not reliable at all. that's why i dont want memory sitting in a session that's allocated and taking up space but not being used. that is unreliable and i have noticed this for long time now. seems like outlook gets confused when using this type approach.

    reason i am sending response is in effort to have 1% of senders call me on the phone. that way i know they worth talking to.

  4. #4
    Banned User!
    Join Date
    01-17-2021
    Location
    Omaha, NE
    MS-Off Ver
    office 2016
    Posts
    211

    Re: code consolidation

    i guess i need to ask,..... if i put constant inside private function, does that mean that is only takes memory whenever that function runs? then when over, the memory is destroyed? if yes, then i will do it. guess i did not know that. thanks.

  5. #5
    Banned User!
    Join Date
    01-17-2021
    Location
    Omaha, NE
    MS-Off Ver
    office 2016
    Posts
    211

    Re: code consolidation

    jazzer,

    i took you suggestion, but it is causing another issue. here what i have

    Please Login or Register  to view this content.
    but i just got email from you tube with this in subject
    Please Login or Register  to view this content.
    and my code sent a response. can this old language do any better than this? it recognized the word "on". i cannot have that. =( i don't think that vba has ability to search in long string like what i have. right?

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: code consolidation

    Quote Originally Posted by omahaNative_1023 View Post
    the constant takes memory and sits unused when the session is running.
    This is not correct. The constant will use memory only when senderIsBad is called and loaded onto the stack. It does not use heap memory.

    Look at the big picture. You are worried about memory performance of subs and functions that take milliseconds to run and take up negligible memory. The string takes up 352 bytes. Nobody worries about 352 bytes when system memory is measured in GB.

    Second, how frequently do you receive email? Unless you are getting hundreds of emails a minute, you will not see any advantage to further optimization of this code. What performance problem are you trying to solve?

    You are searching for each word of the subject to occur anywhere in a string. It is not matching "on", it is matching "a". The word "a" occurs in your string many times. (This will also happen with basic, dot, word, act, work, etc.) To fix this, you must match on entire words. Add a comma at the beginning and end of the test string, and then search for words beginning and ending with a comma.

    Also "l" is a really bad variable name because a(l) looks like a(1) in the VBA window.
    Please Login or Register  to view this content.

  7. #7
    Banned User!
    Join Date
    01-17-2021
    Location
    Omaha, NE
    MS-Off Ver
    office 2016
    Posts
    211

    Re: code consolidation

    Quote Originally Posted by 6StringJazzer View Post
    . Add a comma at the beginning and end of the test string, and then search for words beginning and ending with a comma.
    can you give details on that? not sure i understand. why does adding comma at beginning and end help? thanks. i see your example, but not sure why it helps.

    i was talking about public consts. not your example of const. so yes, i was correct. publics are loaded when program loads. they sit and take memory.

    i get 20-30 of these mails a day

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: code consolidation

    Quote Originally Posted by omahaNative_1023 View Post
    can you give details on that? not sure i understand. why does adding comma at beginning and end help?
    If a word in the subject is "a" instead of matching on "a" you need to match on ",a," to make sure that it matches an entire keyword, not just part of a keyword. So first I recommended adding a comma at the beginning and end of the word you are searching for to guarantee an exact match. If you do that, then you need a comma at the beginning and the end of the list of keywords to be able to match ",php," and ",embedded,".

    i was talking about public consts.
    You were responding to my example and said, "reason i dont want to use constant and use function instead." You made no mention of global or public const.

    i get 20-30 of these mails a day
    No change you make to this code will make any noticeable difference in the time or memory efficiency of this code. It's an academic exercise with no practical benefit. I am the manager of a software development organization that builds systems where we worry about performance when we have 100,000 transactions per hour.

  9. #9
    Banned User!
    Join Date
    01-17-2021
    Location
    Omaha, NE
    MS-Off Ver
    office 2016
    Posts
    211

    Re: code consolidation

    Quote Originally Posted by 6StringJazzer View Post
    You were responding to my example and said, "reason i dont want to use constant and use function instead." You made no mention of global or public const.
    so does that mean that i correct about the pubic const taking up memory when not even being used? when just program boots?

+ 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. Stream lining this code - Consolidation of multiple files to one file
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-13-2018, 04:11 PM
  2. [SOLVED] Consolidation of data From Different Files to one Master workbook, Code Error.
    By structo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-12-2016, 03:29 PM
  3. [SOLVED] Consolidation several tabs' data into a consolidation sheet via a loop?
    By Gti182 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-30-2015, 08:18 AM
  4. Duplicate a column of information in my consolidation code.
    By Dremzy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-27-2014, 08:39 AM
  5. [SOLVED] Help for enhance the code - Excluding Sheet While Consolidation
    By ExcelUser2707 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2014, 05:43 AM
  6. [SOLVED] Data Consolidation and running of code
    By sgmat in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 03-15-2013, 02:34 AM
  7. VBA CODE: consolidation of excel sheets
    By questionmark in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-06-2006, 07:48 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