Results 1 to 4 of 4
  1. #1
    kent is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2019
    Posts
    38

    Difference in SelStart & SelLength in regular vs activeX text boxes


    I've needed to use ActiveX text boxes for some functionality that regular text boxes don't have, and I noticed with the ActiveX text boxes that when using functions like InStr() and Len() that the character locations don't match the locations that SelStart refers to. After some investigation, I found:
    • For standard functions like InStr() and Len(), vbnewlines are counted as 2 characters long
    • For regular text boxes, vbnewlines are counted as 2 characters long by SelStart and SelLength
    • For activeX text boxes, vbnewlines are counted as 1 character long by SelStart and SelLength


    Are there any settings for the activeX text box that can set vbNewLine to be counted as 2 characters by SelStart and SelLength so I don't have to do calculations in VBA to correctly calculate positions in long multiline documents?

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    It’s because in your first two examples a return is chr(10) + chr(13) whilst some apps and active x just use chr(10)

    so no setting you can use to change that

    depends on what you are trying to do but to get comparable lengths you could use the replace function to replace chr(13) with a zls - but repeat, depends on what you are trying to do

  3. #3
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    When both are required, AFAIK the order matters, and I think the order is Chr(13) followed by Chr(10)?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    you are correct

    ?asc(left(vbcrlf,1))
    13

Please reply to this thread with any new information or opinions.

Similar Threads

  1. SelStart textbox problem
    By diegomarino in forum Access
    Replies: 4
    Last Post: 06-10-2022, 07:17 AM
  2. Replies: 1
    Last Post: 05-28-2020, 01:15 PM
  3. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  4. SelStart not accounting from spaces?
    By tylerg11 in forum Forms
    Replies: 2
    Last Post: 06-28-2012, 04:45 PM
  5. SelStart problem
    By ybg1 in forum Access
    Replies: 2
    Last Post: 11-14-2010, 12:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums