Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

get codepage from a rich text box control

Posted on 2005-05-17
3
Medium Priority
?
645 Views
Last Modified: 2012-06-27
Hi,

How can I get and set the codepage from a rich text box

Please Help me
0
Comment
Question by:LPlate
3 Comments
 
LVL 8

Expert Comment

by:pjcrooks2000
ID: 14019535
If I am correct you want to see the code window relevant to the text box then simply in design view and as long as your appication is not running double click on the text box and the code window will appear.

You can then select the events form the right hand side drop down window to perform tasks at relevant event procedures or when each event for the control occurs.

HTH
0
 

Author Comment

by:LPlate
ID: 14019627
Hi HTH,

No thats not what i mean, I have a richtextbox and i need to know what codepage is used at runtime
0
 
LVL 13

Accepted Solution

by:
rettiseert earned 300 total points
ID: 14019930
Hi

You need to read the control word "ansicpg" inside the rtf code, please take a look at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnrtfspec/html/rtfspec_6.asp and then try this code:

Private Sub SetCodePage(cpg As Long, rtb As RichTextBox)

    Dim cpgstart As Long
    Dim cpgend As Long
   
    cpgstart = InStr(1, rtb.TextRTF, "\ansicpg") + Len("\ansicpg") - 1
    cpgend = InStr(cpgstart, rtb.TextRTF, "\")
   
    rtb.TextRTF = Left(rtb.TextRTF, cpgstart) + Format(cpg) + Mid(rtb.TextRTF, cpgend)
   
    rtb.Refresh

End Sub

Private Function GetCodePage(rtb As RichTextBox) As Long

    Dim cpgstart As Long
    Dim cpgend As Long
   
    cpgstart = InStr(1, rtb.TextRTF, "\ansicpg") + Len("\ansicpg")
    cpgend = InStr(cpgstart, rtb.TextRTF, "\")
   
    GetCodePage = CLng(Mid(rtb.TextRTF, cpgstart, cpgend - cpgstart))

End Function
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 8 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question