I am having headache with this one. I have a single rtf ctrl that have a button next to it to make a superscript. That is needed cos the program deals with a local language that needs superscript for explanation purpose. As we are feeding data using a GUI and rtf control seems to do the job,I am going ahead with it.
Now the problem is I cant replace the superscript rtf to html. I tried till this stage: -
Dim k As String = (TextBox1.Rtf)
-
Dim intfs17 As Integer = InStr(k, "\fs17", CompareMethod.Text)
-
'fs17 is the last string in the rtf header i blv
-
If intfs17 > 0 Then
-
'replace till it now. erase till it all.
-
Dim b As New StringBuilder
-
b.Append(k)
-
b.Remove(0, intfs17 + 4) 'removes all the stuff from first char to the word intfs17
-
b.Replace("\par", "")
-
b.Replace("}", "")
-
b.Replace("\up4", "") 'non superscripts or ordinary words
-
'****************************
-
'NOw here I remain with a string that contains words with superscript format. E.g. html wise <sup>a</sup>bc
-
and in rtf wise it is a\up0 bc
-
-
'I thot of the following line but it is obviously going to hog the program very much
-
k = b.ToString
-
Dim i As Integer = 0
-
Dim c As Integer = 0
-
For i = k.Length - 1 To 0
-
If k.Substring(i, 4) = "\up0" Then 'we ve a super script
-
c = i + 4
-
'stuck!
-
-
End If
-
Next
-
-
End If
-
Now my questions are 2:
1. How can I replace \up0 with the right html superscripting?
2. for each char superscripted, rtf separates using a single space. How would i differ that from spaces i am going to use to separate the entered words?
Any any help is greatly appreciated!
2 1693 Luuk 1,047
Expert 1GB
You should not loop through the string, use InSrt instead. -
Dim s as String ="abcde"
-
Dim i as Integer
-
a=Instr(s,"d",1)
-
now a has the value 4.
Am sure there is a better way to do this but since i am in a hurry, i did finish it this way. It wont work if first alpahebt is superscriptted but that is not the case in my form so it is ok... -
Private Function supSub(ByVal inthowmuch As Integer) As String
-
'returns final html'ed word
-
Dim strr As String = ""
-
TextBox1.SelectionCharOffset = inthowmuch
-
TextBox1.SelectedText = TextBox1.SelectedText
-
TextBox1.SelectionCharOffset = 0
-
Dim k As String = (TextBox1.Rtf)
-
Dim intfs17 As Integer = InStr(k, "\fs17", CompareMethod.Text)
-
If intfs17 > 0 Then
-
'replace till it now. erase till it all.
-
Dim b As New StringBuilder
-
b.Append(k)
-
b.Remove(0, intfs17 + 4)
-
b.Replace("\par", "")
-
b.Replace("}", "")
-
b.Replace("\up4", "") 'non pe
-
'see if we ve superscripts within the scriptsb.
-
k = b.ToString
-
k = Trim(k)
-
Dim i As Integer = 0
-
Dim c As Integer = 0
-
Dim p As String()
-
p = k.Split(" ")
-
-
-
Dim r As New Dictionary(Of Integer, Integer)
-
r.Clear()
-
For i = 0 To p.Count - 1
-
If p(i).EndsWith("\up0") = True Then
-
p(i) = "<sup>" & p(i).Replace("\up0", "</sup>")
-
If p(i + 1).EndsWith("\up0") = False Then
-
p(i) = p(i) & p(i + 1)
-
r.Add(i + 1, i + 1)
-
End If
-
If p(i - 1).EndsWith("\up0") = False Then
-
p(i) = p(i - 1) & p(i)
-
r.Add(i - 1, i - 1)
-
End If
-
-
End If
-
Next
-
-
strr = ""
-
For i = 0 To p.Count - 1
-
If r.ContainsKey(i) = False Then
-
strr = strr & p(i) & " "
-
End If
-
-
Next
-
-
End If
-
-
-
Return strr
-
End Function
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: dan |
last post by:
Im sure this has been asked a million times, but Im I couldn't find it.
So, why not make it 1 million +1.
I am looking for the best way to format html, to be put into a INSERT
statement. The...
|
by: Rock |
last post by:
Hi,all:
how to convert VBA #date# format (ex: #2004/3/6#) to C# code ?
here are vba code :
Dim objUserPerm As Office.UserPermission
Set objUserPerm =...
|
by: solomon_13000 |
last post by:
How do I actually convert different video format (avi,mpeg,mp4, etc)
file to a flash format and view it as flash? People would upload their
video files on my server and my server will do the...
|
by: nirmalsingh |
last post by:
i am getting date format in string as 30-11-2006 05:59:44 PM . i want to convert in the format of yyyy-mm-dd hh:mm:ss to sore it in mysql database.
Help me with sample coding plz..
|
by: VinDiesal |
last post by:
Hi Buddies,
I want the Sample source code about How to convert Dss audio format to wav format in .net. Please anybody send the source code for this.
|
by: Academia |
last post by:
I have a vs2003 project (actually 44 of them) that I want to convert to
VS2005 format.
To fix a usercontrol file I created the Designer.vb file and moved the
Inherited and Class ( change to...
|
by: John Krukoff |
last post by:
-----Original Message-----
One method which wouldn't require much python code, would be to run the
XHTML through a simple identity XSL tranform with the output method set to
HTML. It would...
|
by: M.-A. Lemburg |
last post by:
On 2008-04-24 19:16, John Krukoff wrote:
You could filter the XHTML through mxTidy and set the hide_endtags to 1:
http://www.egenix.com/products/python/mxExperimental/mxTidy/
--
Marc-Andre...
|
by: sainathsagar |
last post by:
public void AudioConvert(){
FileStream fs = new FileStream(InputFileName, FileMode.Open, FileAccess.Read);
NAudio.Wave.WaveFormat format = new NAudio.Wave.WaveFormat();
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |