Functions C to T and t to C

Source: Internet
Author: User

Two functions ctot and ttoc are written.

Function ctot $ (ccstr $)
Dim I %, J %, N %, M %, T ()

If ccstr = "" Then exit function
If instr (ccstr, "CHR (") = 0 or instr (ccstr, ")") = 0 Then exit function

Ccstr = Replace (ccstr, "CHR ","")
Ccstr = Replace (ccstr, "+ ","")

I = Len (ccstr)-len (replace (ccstr ,"(",""))
J = Len (ccstr)-len (replace (ccstr ,")",""))
N = IIF (I> J, J, I)
'The above is a canonicalized and formatted string.

Redim T (1 to n)
I = 1: j = 1
For M = 1 to n
I = instr (J, ccstr ,"(")
J = instr (I + 1, ccstr ,")")
T (m) = CHR (mid (ccstr, I + 1, J-I-1 ))
Next
Ctot = join (T ,"")
End Function

Function ttoc $ (txtstr $)
Dim I %, N %, C ()
N = Len (txtstr)
If n <> 0 then
Redim C (1 to n)
For I = 1 to n
C (I) = ASC (mid (txtstr, I, 1 ))
Next
Ttoc = "CHR (" & join (C, ") + CHR (")&")"
End if
End Function

Private sub text=change ()
Text2 = ctot (text1)
End sub

Private sub text2_change ()
'Text1' = ttoc (text2)
'Two cannot be used at the same time. Haha, or two text boxes will be reversed.
'You can add a text3 to get it.
'The input content in 1 is CHR to 3
'Input in 2, ASC to 3
End sub

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.