none
Playing card suits special characters RRS feed

  • Question

  • ASCII codes 3, 4, 5 and 6 should be the symbols for the playing card suits.  I'd like to store these symbols in a table as STRING type values, but first I need to be able to type them (or write code to capture the values).  Getting them saved in a table won't be a problem.

    The following code almost works in Access 2007:

       Dim TextValue as String

       TextValue = Chr (65)       ' This writes the letter 'A' to TextValue as expected  

       TextValue = Chr (3)         ' This should return the 'Diamond' symbol to TextValue, but it returns a different symbol likewise                                             ' for Hearts, Clubs and Spades

    The same code in Access 2016 returns TextValue = " " regardless of the ASCII value I enter

    Any ideas on what might need to be configured in ACCESS 2016 to get this to work and for extra points what ASCII values might the suit symbols be?  Or, better yet, how else might I be able to store and display the suit symbols

    Thank you for any assistance

    Norm

    Friday, November 8, 2019 5:49 AM

Answers

  • Oh my - the good  old DOS days and  text output!

    ‑­ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]

    ^_`abcdefghijklmnopqrstuvwxyz{|}~ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñÑ

    ªº¿®¬½¼¡«»░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐└┴┬├─┼ãÃ╚╔╩╦╠═╬¤ðÐÊËÈıÍÎÏ┘┌█▄¦Ì▀ÓßÔÒõÕµþÞÚÛÙýݯ´­±‗¾¶§÷¸°¨·¹³²■ END default

    You will find that most text output today will NOT respect the first (lower) characters that included the basic characters that oh so many DOS games included on the IBM PC. However, the above DOES show the classic "block" chars and line drawing chars. 

    Fear not, you can display the card suites.

    If you use Ariel, Courier new and a few others as a text box in Access?

    Then you can insert the ♥ for example.

    Note that while in word, or even a access text box?

    You can hold down the alt key and then enter the ASCII/Unicode character.

    You MUST use the number pad to do this.

    You MUST keep holding the alt key down while you enter the value on the number key pad (so hit num lock before you do this).

    The above trick still works in windows 10, and I think goes back to DOS days!!!

    So, while typing this post, I hit alt key (keep holding it down) and then hit the 3 key (must use number  keypad). Now, let go of alt key. You will get this for alt 3  

    However fonts and uni-code characters  in windows could take about the same  time it takes to earn a medical degree as to how this works. (a VERY complex subject).

    As the above 0-255 cut+ paste shows, the ASCII chr(3) don’t’ return a heart in windows. You need a uni-code value.

    Turns out that 3 gets translated to character 9829

    So you can also use att key, and enter 9829 and I get this:♥

    So, you can display + use these chars in VBA. But, while char(ASCII number) is limited 0-255, the above is in the 9000’s.

    (yes, you have 10,000 characters or more!!!) - remember that required medical degree here!

    So, you can use charW( some uni-code value) in VBA. So, turns out VBA DOES have some uni-code functions.

    So, place a button on a access form. Create a nice big text box, and use this VBA code. The values for the cards are set in this code:

       Dim Spade As String
       Spade = ChrW(9824) 'Spade
       Dim Clubs As String
       Clubs = ChrW(9827) 'Club
       Dim Hearts As String
       Hearts = ChrW(9829)  'Heart
       Dim Diamond As String
       
       Diamond = ChrW(9830)  'Diamond
    
       ' display  in text box
       
       Me.Text0 = "3 spades " & Spade & " " & Spade & " " & Spade & vbCrLf
       
       Me.Text0 = Me.Text0 & "3 Clubs " & Clubs & " " & Clubs & " " & Clubs & vbCrLf
       
       Me.Text0 = Me.Text0 & "3 Hearts " & Hearts & " " & Hearts & " " & Hearts & vbCrLf
       
       Me.Text0 = Me.Text0 & "3 Diamond " & Diamond & " " & Diamond & " " & Diamond & vbCrLf
       
       

    The result is this:

    

    And, do you want color?

    Well, change the above text box to rich text format.

    Now, we are using rtf markup. It’s close to HTML.

    Now, lets use this code:

    Private Sub Command4_Click()
    
       Dim Spade As String
       Spade = "<font color=black>" & ChrW(9824) & "</font>"
       
       Dim Clubs As String
       Clubs = "<font color=black>" & ChrW(9827) & "</font>"
       
       Dim Hearts As String
       Hearts = "<font color=red>" & ChrW(9829) & "</font>"
       
       Dim Diamond As String
       Diamond = "<font color=red>" & ChrW(9830) & "</font>"
    
       Dim StartOfLine As String
       Dim EndOfLine As String
       
       StartOfLine = "<div>"
       EndOfLine = "</div>"
       
       Me.Text0 = ""
       
       Me.Text0 = StartOfLine & "3 Spades  :" & Spade & " " & Spade & " " & Spade & EndOfLine
       
       Me.Text0 = Me.Text0 & StartOfLine & "3 Clubs   :" & Clubs & " " & Clubs & " " & Clubs & EndOfLine
       
       Me.Text0 = Me.Text0 & StartOfLine & "3 Hearts  :" & Hearts & " " & Hearts & " " & Hearts & EndOfLine
       
       Me.Text0 = Me.Text0 & StartOfLine & "3 Diamonds:" & Diamond & " " & Diamond & " " & Diamond & EndOfLine
    
    End Sub

    We get this:

    However, if I was going to do this? I will actually go find a font for windows that can render cards. There are lots to be found - just google play card fonts for windows.

    So, if we select the font, then our form looks like this:

    Not only that, but the cards are simple ABCDEF characters, so you can type them in, or display  them in access forms with great ease - and you not be dealing with funny and strange codes. To display the above I did this:

    me.textbox0 = "ABCDEF"

    So each letter of the font is a WHOLE card. Toss in rich  text, and I formatted the above as red cards.

    Regards,

    Albert D. Kallal (Access MVP 2003-2017)

    Edmonton, Alberta Canada


    Saturday, November 9, 2019 1:51 AM

All replies

  • Any ideas on what might need to be configured in ACCESS 2016 to get this to work and for extra points what ASCII values might the suit symbols be?  Or, better yet, how else might I be able to store and display the suit symbols

    Hi Norm,

    You could use the "Symbol" font, with ASCII values 167 - 170.

    Imb.


    • Edited by Imb-hb Friday, November 8, 2019 9:36 AM edit
    Friday, November 8, 2019 9:33 AM
  • Oh my - the good  old DOS days and  text output!

    ‑­ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]

    ^_`abcdefghijklmnopqrstuvwxyz{|}~ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñÑ

    ªº¿®¬½¼¡«»░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐└┴┬├─┼ãÃ╚╔╩╦╠═╬¤ðÐÊËÈıÍÎÏ┘┌█▄¦Ì▀ÓßÔÒõÕµþÞÚÛÙýݯ´­±‗¾¶§÷¸°¨·¹³²■ END default

    You will find that most text output today will NOT respect the first (lower) characters that included the basic characters that oh so many DOS games included on the IBM PC. However, the above DOES show the classic "block" chars and line drawing chars. 

    Fear not, you can display the card suites.

    If you use Ariel, Courier new and a few others as a text box in Access?

    Then you can insert the ♥ for example.

    Note that while in word, or even a access text box?

    You can hold down the alt key and then enter the ASCII/Unicode character.

    You MUST use the number pad to do this.

    You MUST keep holding the alt key down while you enter the value on the number key pad (so hit num lock before you do this).

    The above trick still works in windows 10, and I think goes back to DOS days!!!

    So, while typing this post, I hit alt key (keep holding it down) and then hit the 3 key (must use number  keypad). Now, let go of alt key. You will get this for alt 3  

    However fonts and uni-code characters  in windows could take about the same  time it takes to earn a medical degree as to how this works. (a VERY complex subject).

    As the above 0-255 cut+ paste shows, the ASCII chr(3) don’t’ return a heart in windows. You need a uni-code value.

    Turns out that 3 gets translated to character 9829

    So you can also use att key, and enter 9829 and I get this:♥

    So, you can display + use these chars in VBA. But, while char(ASCII number) is limited 0-255, the above is in the 9000’s.

    (yes, you have 10,000 characters or more!!!) - remember that required medical degree here!

    So, you can use charW( some uni-code value) in VBA. So, turns out VBA DOES have some uni-code functions.

    So, place a button on a access form. Create a nice big text box, and use this VBA code. The values for the cards are set in this code:

       Dim Spade As String
       Spade = ChrW(9824) 'Spade
       Dim Clubs As String
       Clubs = ChrW(9827) 'Club
       Dim Hearts As String
       Hearts = ChrW(9829)  'Heart
       Dim Diamond As String
       
       Diamond = ChrW(9830)  'Diamond
    
       ' display  in text box
       
       Me.Text0 = "3 spades " & Spade & " " & Spade & " " & Spade & vbCrLf
       
       Me.Text0 = Me.Text0 & "3 Clubs " & Clubs & " " & Clubs & " " & Clubs & vbCrLf
       
       Me.Text0 = Me.Text0 & "3 Hearts " & Hearts & " " & Hearts & " " & Hearts & vbCrLf
       
       Me.Text0 = Me.Text0 & "3 Diamond " & Diamond & " " & Diamond & " " & Diamond & vbCrLf
       
       

    The result is this:

    

    And, do you want color?

    Well, change the above text box to rich text format.

    Now, we are using rtf markup. It’s close to HTML.

    Now, lets use this code:

    Private Sub Command4_Click()
    
       Dim Spade As String
       Spade = "<font color=black>" & ChrW(9824) & "</font>"
       
       Dim Clubs As String
       Clubs = "<font color=black>" & ChrW(9827) & "</font>"
       
       Dim Hearts As String
       Hearts = "<font color=red>" & ChrW(9829) & "</font>"
       
       Dim Diamond As String
       Diamond = "<font color=red>" & ChrW(9830) & "</font>"
    
       Dim StartOfLine As String
       Dim EndOfLine As String
       
       StartOfLine = "<div>"
       EndOfLine = "</div>"
       
       Me.Text0 = ""
       
       Me.Text0 = StartOfLine & "3 Spades  :" & Spade & " " & Spade & " " & Spade & EndOfLine
       
       Me.Text0 = Me.Text0 & StartOfLine & "3 Clubs   :" & Clubs & " " & Clubs & " " & Clubs & EndOfLine
       
       Me.Text0 = Me.Text0 & StartOfLine & "3 Hearts  :" & Hearts & " " & Hearts & " " & Hearts & EndOfLine
       
       Me.Text0 = Me.Text0 & StartOfLine & "3 Diamonds:" & Diamond & " " & Diamond & " " & Diamond & EndOfLine
    
    End Sub

    We get this:

    However, if I was going to do this? I will actually go find a font for windows that can render cards. There are lots to be found - just google play card fonts for windows.

    So, if we select the font, then our form looks like this:

    Not only that, but the cards are simple ABCDEF characters, so you can type them in, or display  them in access forms with great ease - and you not be dealing with funny and strange codes. To display the above I did this:

    me.textbox0 = "ABCDEF"

    So each letter of the font is a WHOLE card. Toss in rich  text, and I formatted the above as red cards.

    Regards,

    Albert D. Kallal (Access MVP 2003-2017)

    Edmonton, Alberta Canada


    Saturday, November 9, 2019 1:51 AM
  • If you use Ariel, Courier new and a few others as a text box in Access?

    Then you can insert the ♥ for example.

    Thank you. Albert, for given me the Unicode number for Spade etc. It could not find it quick enough.

    For all these special characters I use a different route.

    On each form of all my applications I have a "Zoom" button. Clicking this button opens a Zoom_form, where the contents of the active control is diplayed in one large control, covering many more lines than in the original, if necessary. This Zoom_form has also many buttons for a multitude of text-manipulations. A.o. convert the selected part to UpperCase or LowerCase, count the number of words, letters, and statistics of letters, revert the text, show ASCII-values, etc, etc.

    But the form has also a button for SpecialCharacters. Clicking on this button opens a next form with a page of Unicode characters. You can scroll through the pages, until you have found the right page.

    A DblClick will insert this Unicode character on the place of the cursor in the original text. It can be used to insert the card symbols, but also to adjust the names of persons that contain non-Latin characters.

    The nice thing is that this functionality is captured in a linked library database, and so ready to use in any of my applications in any control.

    A next extension of the functionality could be some kind of index that helps the user to find the right page.

    Imb.

    Saturday, November 9, 2019 8:49 PM
  • Wow! Extra points indeed.  I think the answer was in the first paragraph, but there are so many ideas jumping out of the rest of the answer.  Thank you 

    Thanks a bunch as always Norm

    Monday, November 11, 2019 5:13 AM
  • So many options.  I did find that I had to use the number pad with the alt key

    Thanks a bunch as always Norm

    Monday, November 11, 2019 5:15 AM