-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: Pratap
Message 2 in Discussion
Hi GLPrasad, Have a wonderful day!!! Here is a sample code which can solve ur problem
Iam reading a Textfile which contains HTML tags and iam reading them using filestreams
and replacing the contents with something blah blah blah. Here i am replacing some
contents with database fields (like MailMerge), but iam not giving database accessing
code etc etc. pls follow Pls let me know if u find any difficulty!!! Enjoy
------------------------------------------------ FILE_NAME="C:\SomeFile.txt" Dim sr
As StreamReader = File.OpenText(FILE_NAME)
Dim input1 As String
Try
input1 = sr.ReadLine() '' ******** Formatting
**************
If InStr(input1, "&", CompareMethod.Text) > 0 Then
input1 = Replace(input1, "<", "<", , , CompareMethod.Text)
input1 = Replace(input1, ">", ">", , , CompareMethod.Text)
' input1 = Replace(input1, "&nbsp;", " ", , ,
CompareMethod.Text)
input1 = Replace(input1, "&", "&", , , CompareMethod.Text)
' ' *********************************************
End If
' ********** Field Formatting *************** '
********** Field Formatting *************** If InStr(input1,
"<<", CompareMethod.Text) > 0 Then
'input1 = Replace(input1, "<<",
"dset.Tables(0).Rows(0).Item('", , , CompareMethod.Text)
'input1 = Replace(input1, ">>", "')", , , CompareMethod.Text)
Dim lPosition As Integer = InStr(input1, "<<",
CompareMethod.Text)
Dim rPosition As Integer = InStr(input1, ">>",
CompareMethod.Binary)
Dim strng As String = input1.Substring(lposition + 7, (rposition -
(lposition + 8)))
Dim Cntr As Integer = 0
Do While lPosition > 0
Cntr = Cntr + 1
Dim Str2Replace As String
Dim i As Integer
For i = 0 To dSet.Tables(0).Columns.Count - 1
If dSet.Tables(0).Columns(i).ColumnName = strng Then
If IsDBNull(dSet.Tables(0).Rows(0).Item(i)) Then
str2replace = ""
Else
Str2Replace = dSet.Tables(0).Rows(0).Item(i)
End If
Exit For
End If
Next
input1 = Replace(input1, "<<", "", Cntr, 1,
CompareMethod.Text)
input1 = Replace(input1, ">>", "", Cntr, 1,
CompareMethod.Text)
input1 = Replace(input1, strng, Str2Replace, , ,
CompareMethod.Text) lPosition = InStr(input1, "<<",
CompareMethod.Text)
rPosition = InStr(input1, ">>", CompareMethod.Binary)
If lposition > 0 Then
strng = input1.Substring(lposition + 7, (rposition -
(lposition + 8)))
End If
Loop End If
Catch ei As IOException
Response.Redirect("ErrorPage.aspx?msg=" & ei.Message & "&st=" & ei.StackTrace &
"&erType=IO") End Try ' ********** End of Field Formatting
***********
' ************ End of Formating *************
Try input1 = Replace(input1, "<P>", "<P align='justify'>",
, , CompareMethod.Text)
input1 = Replace(input1, "align='justify'>", "<P align='justify'>", ,
, CompareMethod.Text) While Not input1 Is Nothing
RTF_INPUT1 = input1
RTF_INPUT1 = Replace(RTF_INPUT1, "<P align='justify'>", "\par ", ,
, CompareMethod.Text)
RTF_INPUT1 = Replace(RTF_INPUT1, "<P>", "\par ", , ,
CompareMethod.Text) RTF_INPUT1 = Replace(RTF_INPUT1, "</P>",
"\pard ", , , CompareMethod.Text)
RTF_INPUT1 = Replace(RTF_INPUT1, "<P align='justify'>", "\par \qj
", , , CompareMethod.Text) RTF_INPUT1 = Replace(RTF_INPUT1,
" ", "\sa1", , , CompareMethod.Text)
RTF_INPUT1 = Replace(RTF_INPUT1, "<b>", "\b", , ,
CompareMethod.Text)
RTF_INPUT1 = Replace(RTF_INPUT1, "</b>", "\b0", , ,
CompareMethod.Text) RTF_INPUT1 = Replace(RTF_INPUT1, "<i>", "\i",
, , CompareMethod.Text)
RTF_INPUT1 = Replace(RTF_INPUT1, "</i>", "\i0", , ,
CompareMethod.Text) RTF_INPUT1 = Replace(RTF_INPUT1, "<u>", "\ul",
, , CompareMethod.Text)
RTF_INPUT1 = Replace(RTF_INPUT1, "</u>", "\ul0", , ,
CompareMethod.Text)
RTF_OUTPUT1 &= RTF_INPUT1
Response.Write(input1)
input1 = sr.ReadLine() '' ******** Formatting
**************
If InStr(input1, "&", CompareMethod.Text) > 0 Then
input1 = Replace(input1, "<", "<", , , CompareMethod.Text)
input1 = Replace(input1, ">", ">", , , CompareMethod.Text)
' input1 = Replace(input1, "&nbsp;", " ", ,
, CompareMethod.Text)
input1 = Replace(input1, "&", "&", , , CompareMethod.Text)
' ' *********************************************
input1 = Replace(input1, "<P>", "<P align='justify'>", , ,
CompareMethod.Text)
input1 = Replace(input1, "align='justify'>", "<P
align='justify'>", , , CompareMethod.Text)
'input1 = Replace(input1, ">", ">", , , CompareMethod.Text)
' input1 = Replace(input1, "&nbsp;", " ", ,
, CompareMethod.Text)
'input1 = Replace(input1, "&", "&", , ,
CompareMethod.Text)
' ' *********************************************
End If
' ************ End of Formating *************
' ********** Field Formatting ***************
If InStr(input1, "<<", CompareMethod.Text) > 0 Then
'input1 = Replace(input1, "<<",
"dset.Tables(0).Rows(0).Item('", , , CompareMethod.Text)
'input1 = Replace(input1, ">>", "')", , ,
CompareMethod.Text)
Dim lPosition As Integer = InStr(input1, "<<",
CompareMethod.Text)
Dim rPosition As Integer = InStr(input1, ">>",
CompareMethod.Binary)
Dim strng As String = input1.Substring(lposition + 7,
(rposition - (lposition + 8)))
Dim Cntr As Integer = 0
Do While lposition > 0
cntr += 1
Dim Str2Replace As String
Dim i As Integer
For i = 0 To dSet.Tables(0).Columns.Count - 1
If dSet.Tables(0).Columns(i).ColumnName = strng Then
If IsDBNull(dSet.Tables(0).Rows(0).Item(i)) Then
str2replace = ""
Else
Str2Replace = dSet.Tables(0).Rows(0).Item(i)
End If
Exit For
End If
Next
input1 = Replace(input1, "<<", "", Cntr, 1,
CompareMethod.Text)
input1 = Replace(input1, ">>", "", Cntr, 1,
CompareMethod.Text) 'input1 = Replace(input1, "<<",
"", , , CompareMethod.Text)
'input1 = Replace(input1, ">>", "", , ,
CompareMethod.Text)
input1 = Replace(input1, strng, Str2Replace, , ,
CompareMethod.Text) lPosition = InStr(lposition, input1,
"<<", CompareMethod.Text)
If lposition > 0 Then
rPosition = InStr(lposition, input1, ">>",
CompareMethod.Text)
strng = input1.Substring(lposition + 7, (rposition -
(lposition + 8)))
End If
Loop End If '
********** End of Field Formatting ***********
End While Catch ei As IOException
Response.Redirect("ErrorPage.aspx?msg=" & ei.Message & "&st=" & ei.StackTrace &
"&erType=IO")
' Me.TEXTAREA1.Value = RTF_INPUT1 End Try
sr.Close() ------------------------------------------------ Regards Pratap
I R Banlgaore Mobile : 94480 85015
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]