+ Reply to Thread
Results 1 to 11 of 11

ID a position on str for a set of chars which mean certain labels appear in diff positions

  1. #1
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Gibraltar, Gibraltar
    MS-Off Ver
    365
    Posts
    150

    ID a position on str for a set of chars which mean certain labels appear in diff positions

    In a ComboBox on a UserForm I use the following:

    Please Login or Register  to view this content.
    This populates the TextBox81 Fine. A Command Button later uses it to do this:

    Please Login or Register  to view this content.
    Then in the ComboBox code it does this:

    Please Login or Register  to view this content.
    It has 6 other If statements so it could produce this 28 character string:

    e.g.

    TextBox72.Value = "aNOxbYEScYESdYESeYESfYESgYES"

    Then a particular piece of code (there are 6 more pieces) Counts how many CommandButtons are Enabled = False

    Please Login or Register  to view this content.
    Then much further down the ComboBox code I have this:

    Please Login or Register  to view this content.
    And it is not populating TextBox76 or editing the label (so it appears in the correct position in a Frame). Can you see where this goes wrong?
    Last edited by Michael Island; 05-20-2020 at 05:34 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,860

    Re: Not sure why code does not work

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however the thread title does not really convey what your request is about. Tell us what you are trying to do, not how you think it should be done.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Gibraltar, Gibraltar
    MS-Off Ver
    365
    Posts
    150

    Re: Not sure why code does not work

    Done, now can you help me please.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,170

    Re: ID a position on str for a set of chars which mean certain labels appear in diff posit

    And it is not populating TextBox76 or editing the label (so it appears in the correct position in a Frame). Can you see where this goes wrong?
    See yellow top banner
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  5. #5
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Gibraltar, Gibraltar
    MS-Off Ver
    365
    Posts
    150

    Re: ID a position on str for a set of chars which mean certain labels appear in diff posit

    Hi sintech the code shows what is happening. If I include the worksheet with the hundreds of lines of VB code for the objects in this userform it will take months or weeks to go through it. Do you really need the Excel attached?

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,170

    Re: ID a position on str for a set of chars which mean certain labels appear in diff posit

    It has 6 other If statements so it could produce this 28 character string:
    Then a particular piece of code (there are 6 more pieces)
    And it is not populating TextBox76 or editing the label
    Please Login or Register  to view this content.
    So...Somewhere in this haystack of code of which half is not shown your criteria is not being met...Therefore it is bypassing this...
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Gibraltar, Gibraltar
    MS-Off Ver
    365
    Posts
    150

    Re: ID a position on str for a set of chars which mean certain labels appear in diff posit

    I have created a form as a UserForm and made it that the CommandButtons next to the TextBoxes become Enabled = True if the TextBox contents match a set of rules or the CommandButtons next to the TextBoxes become Enabled = False if the TextBox contents do not match a set of rules. On clicking this ComboBox it creates a string telling me what CommandButtons are Enabled = False (e.g. "aNOxbYEScYESdYESeYESfYESgYES") which is put in TextBox72. Then the code in ComboBox counts how many fields need to be fixed (in this case 1) and puts that in TextBox77. This tells me the size of the Frame required to display 1 'field row to fix' Label. The last bit of code tells me which fields, in order, need to be fixed by making the relevant Label visible and positioned correctly in a Frame and populating TextBox76 with only the negative code e.g. "aNOx". I will later use it for another purpose. If you want I can show you the code in the ComboBox?

  8. #8
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,150

    Re: ID a position on str for a set of chars which mean certain labels appear in diff posit

    Quote Originally Posted by Michael Island View Post
    ... not populating TextBox76 ... where this goes wrong?
    Value in "TextBox81" <> 9 and in "TextBox77" <> 1, because the text fields contain text and not numeric values, "9" <> 9 and "1" <> 1.


    Ps:

    Topic title is highly unclear - change title
    Last edited by mjr veverka; 05-19-2020 at 12:57 PM.

  9. #9
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Gibraltar, Gibraltar
    MS-Off Ver
    365
    Posts
    150

    Re: ID a position on str for a set of chars which mean certain labels appear in diff posit

    Hi I changed 'TextBox81.Value = 9' TO 'TextBox81.Value = "9" ' and 'TextBox77.Value = 1' TO 'TextBox77.Value = "1" ' and all worked fine so I'll set the Thread to 'SOLVED' and ADD to your reputation.

  10. #10
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,150

    Re: ID a position on str for a set of chars which mean certain labels appear in diff posit

    Ok, nice ... : )
    ... but when it comes to identifying which of the buttons is active / inactive, you should do it using variables, then you have greater possibilities of operating on data, why refer to the text fields of the form every time ?

  11. #11
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Gibraltar, Gibraltar
    MS-Off Ver
    365
    Posts
    150

    Re: ID a position on str for a set of chars which mean certain labels appear in diff posit

    Noted. Use Variables to avoid this issue on small number sets. OK

+ 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. [SOLVED] Setting Print area with VBA code on active sheet - Can't get my code to work
    By hans302 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-14-2017, 05:07 AM
  2. Testing single code, work fine. Put multiple codes in one sheet, one code doesn't work.
    By MayDay1988 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-30-2017, 06:14 PM
  3. Code will not work when followed by more code (does work when stepped through)
    By Cashgenerator in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-03-2015, 10:12 AM
  4. [SOLVED] Need help with VBA code. Tons of code seperated in two, second part of code doesn't work.
    By FragaGeddon in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 11-30-2015, 11:46 AM
  5. Replies: 9
    Last Post: 08-30-2013, 07:49 AM
  6. Replies: 1
    Last Post: 08-14-2013, 12:01 PM
  7. [SOLVED] hELP FOR MY PROJECT (IN PROJECT SHEET CODE NOT WORK,, OUTSIDE THAT CODE WORK)
    By santosh226001 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 08-06-2013, 06:53 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