Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195

    What are these blocks, can't remove them

    Hi Guy's hoping you can help with this

    the snip is a debug, when getting data from a text box

    Salutation (ct)
    First Name (fn)
    Last Name(ln)

    I am trying allsorts to remove these blocks such as Replace / LTrim strings

    I have never seen this before!!, i have searched a few places and know you great people will know what these little blocks are ?

    Click image for larger version. 

Name:	Screenshot.png 
Views:	33 
Size:	41.9 KB 
ID:	50799

    Code:
    Dim ct() As String, sct As String, ict As Integer            
                 ct = Split(strMailMessage, vbCrLf)
                    For ict = 0 To UBound(ct)
                        If InStr(1, ct(ict), "Salutation:") > 0 Then
                            sct = Mid(ct(ict + 2), 1) & vbCrLf & vbCrLf
                        Exit For
                        End If
                    Next ict
                sct = LTrim(sct)
                sct = Replace(sct, Chr(13) & Chr(10), "")
                Me.txtName = LTrim(sct)
                
                Dim fn() As String, sfn As String, ifn As Integer
                fn = Split(strMailMessage, vbCrLf)
                    For ifn = 0 To UBound(fn)
                        If InStr(1, fn(ifn), "First Name:") > 0 Then
                            sfn = Mid(fn(ifn + 2), 1) & vbCrLf & vbCrLf
                        End If
                    Next ifn
                sfn = LTrim(sfn)
                sfn = Replace(sfn, Chr(13) & Chr(10), "")
                
                Dim ln() As String, sln As String, strFN As String, iln As Integer
                ln = Split(strMailMessage, vbCrLf)
                    For iln = 0 To UBound(ln)
                        If InStr(1, ln(iln), "Last Name:") > 0 Then
                            sln = Mid(ln(iln + 2), 1) & vbCrLf & vbCrLf
                        Exit For
                        End If
                    Next iln
                sln = LTrim(sln)
                Me.txtName = ""
                Me.txtName = sct & " " & sfn & " " & sln
                Me.txtName = Replace(Replace(Me.txtName, Chr(13) & Chr(10), ""), Chr(8), LTrim(Me.txtName))


  2. #2
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Examine the string in something like Notepad ++ , turn on the view symbol option.
    That should tell you what character they really are, and allow you to do something about them.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    or loop through the string to determine the ascii code

    Code:
    dim i as integer
    
    for i=1 to len(str)
        debug.print asc(mid(str,i,1)); ' mid(str,i,1) if you want to see the character, note some non printing characters, such as line feeds may split line
    next i

  4. #4
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    @ Minty, will look up about Notepad ++, never used before nor know what it is but will look up

    @CJ London, yes because if i am reading your suggestion correctly, once I find the Chr code of this block, i guess then replace/Trim function ?

    Thank you anyway, totally appreciate your input, will come back to it a little later

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,944
    Will not be the Trim() function, just the Replace().
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Hi Guy's thank you, so based on CJ London Suggestion

    Based on this part of code

    Code:
                For i = 1 To Len(Me.txtName)                
                   Debug.Print Asc((Mid(Me.txtName, i, 1)))
                Next i
    Debug

    Code:
    77  114 
     9 
     32 
     68 
     97 
     118 
     105 
     100 
     9 
     32 
     77 
     111 
     115 
     101 
     115 
     9
    Does this mean i need to replace these numbers In the String or Text Box ?

  7. #7
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    the string

    replace(str,chr(num),"")

    replace num with whatever

    this is a link to ascii codes
    https://www.ascii-code.com/

    the number relates to the DEC column so 77 is the letter M, 32 the space character, 9, the horizontal tab, etc

  8. #8
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    I use the same as CJ but print the character and the ascii value.

    Code:
    Sub FindNonPrintables(StrIN As String)
        Dim i As Integer
    
    
        For i = 1 To Len(StrIN)
            Debug.Print Mid(StrIN, i, 1), Asc(Mid(StrIN, i, 1))
        Next i
    
    
    End Sub
    In looking through the ascii tables I don't see anything resembling a square. I'm curious what its value is.

    I also tried
    Code:
        Dim i As Integer
        For i = 1 To 255
            Debug.Print Chr(i)
        Next
    but again nothing resembling a square.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  9. #9
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Hi guys the penny has dropped, I believe each number is the charchter within the string, text box, so is it a matter of counting where the blocks shouldn't be and that gives me the chr number to remove ?

  10. #10
    Join Date
    Apr 2017
    Posts
    1,681
    Probably you have got strings containing some unicode characters from somewhere - most probably by copying and inserting some data from internet. For some languages (e.g. chinese, or arabian languages) those are only characters used, for some other (like languages using cyrillic schrift, or some european languages using characters not present in main ASCII table) it may be mixed up. And there may be several characters which have different unicode values, but look identical or almost same, as some character from regular latin alfabet (so when you compare strings which look same, they really may be different).
    Also, some schrifts used by some websites can be based on unicode characters.

    You get a box (or some other shape) displayed instead of character, when language or font, your OP-system is using, is not able to display it properly.

  11. #11
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    I use the same as CJ but print the character and the ascii value.
    I did provide the code, but Dave chose not to use it
    In looking through the ascii tables I don't see anything resembling a square. I'm curious what its value is.
    It just means the character cannot be displayed - almost certainly the horizontal tab character in this case

  12. #12
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    FYI -Crystal/strive4peace has a function to display a string and the ASCII code for each character in the string. Handy for debugging or reference.

    Click image for larger version. 

Name:	2023-09-21 08_53_50-What is ASCII for each character_ — Mozilla Firefox.png 
Views:	27 
Size:	84.2 KB 
ID:	50800
    Last edited by orange; 09-21-2023 at 09:10 AM. Reason: added png

  13. #13
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    Quote Originally Posted by CJ_London View Post
    I did provide the code, but Dave chose not to use it
    It just means the character cannot be displayed - almost certainly the horizontal tab character in this case
    Yea, I saw you had it commented out.

    Hi guys the penny has dropped, I believe each number is the charchter within the string, text box, so is it a matter of counting where the blocks shouldn't be and that gives me the chr number to remove ?
    If you used Cj's or my code you would get
    Code:
    H              72 
    e              101 
    l              108 
    l              108 
    o              111 
                   32 
    W              87 
    o              111 
    r              114 
    l              108 
    d              100
    much easier to spot.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  14. #14
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Hi guys thank you

    @ArviLaanemets

    Yes correct, we have changed web host, i am taking enquiries from HubSpot, the new emails come through on a form where is used to be a mail body, data is transferred to text box then split as per initial post

    all of your posts are very handy for me to analyse

  15. #15
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Hi CJ London, i have just seen your code now, sorry i have been sporadically coming back to this topic!!

    your code on post 7 should clear spaces in string, is that I tried by using Replace(String,Chr(13) & Chr(10), "") ?

    Please forgive me if i have mis-read your code

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 04-07-2019, 07:08 AM
  2. Excel refresh blocks Access data entry
    By simaonobrega in forum Import/Export Data
    Replies: 4
    Last Post: 06-30-2017, 11:01 AM
  3. Importing huge files blocks Access
    By dskysmine in forum Import/Export Data
    Replies: 1
    Last Post: 06-14-2012, 08:24 AM
  4. Comment and Uncomment blocks of code
    By TheShabz in forum Tutorials
    Replies: 2
    Last Post: 12-14-2011, 10:23 AM
  5. Try to remove everything to the right of SF
    By murphy in forum Queries
    Replies: 2
    Last Post: 09-15-2011, 03:20 PM

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