|
-
Dec 5th, 2008, 08:02 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] [2005] Html Coding to be displayed in Textbox
Hello sir,
I want HTML coding to be displayed in textbox.
I having 3 forms. When i press button in form2 the code to be executed.
So i used the coding below. But am gettting the path of that html file as output. But i actually wants only the code to be displayed.
Code:
Private Sub LinkLabel4_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel4.LinkClicked
Form3.TextBox.Text = (Application.StartupPath & "\Check\c4.html\")
Form3.Show()
End Sub
-
Dec 5th, 2008, 08:27 AM
#2
Re: [2005] Html Coding to be displayed in Textbox
Thats right - you are setting the textbox's text property to a string which just happens to be the path of a file.
A textbox isn't capable of loading an HTML file directly (or any other file for that matter).
You would need to read the html into a string and then set the text box's text property to that string.
-
Dec 5th, 2008, 08:31 AM
#3
Re: [2005] Html Coding to be displayed in Textbox
Something along the lines of
vb Code:
Imports System.IO Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Try Dim line As String Dim sHTML as String Dim readFile As System.IO.TextReader = New _ StreamReader((Application.StartupPath & "\Check\c4.html\") ) While True line = readFile.ReadLine() If line Is Nothing Then Exit While Else sHTML = sHTML & line & vbCrLf End If End While readFile.Close() readFile = Nothing TextBox.Text = sHTML Catch ex As IOException MsgBox(ex.ToString) End Try End Sub End Class
-
Dec 5th, 2008, 09:11 AM
#4
Thread Starter
Fanatic Member
Re: [2005] Html Coding to be displayed in Textbox
 Originally Posted by keystone_paul
Something along the lines of
vb Code:
Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim line As String
Dim sHTML as String
Dim readFile As System.IO.TextReader = New _
StreamReader((Application.StartupPath & "\Check\c4.html\")
)
While True
line = readFile.ReadLine()
If line Is Nothing Then
Exit While
Else
sHTML = sHTML & line & vbCrLf
End If
End While
readFile.Close()
readFile = Nothing
TextBox.Text = sHTML
Catch ex As IOException
MsgBox(ex.ToString)
End Try
End Sub
End Class
I used your coding but i am getting this error during runtime.
-
Dec 5th, 2008, 09:14 AM
#5
Hyperactive Member
Re: [2005] Html Coding to be displayed in Textbox
Remove the extra slash at the end of the filename:
Code:
StreamReader((Application.StartupPath & "\Check\c4.html\"))
Code:
StreamReader((Application.StartupPath & "\Check\c4.html"))
Did I help you with your problem? If I did rate me by clicking here: Rate knxrb

-
Dec 5th, 2008, 09:35 AM
#6
Re: [2005] Html Coding to be displayed in Textbox
Sorry I didn't check with your exact filename - as knxrb says just remove the trailing backslash!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|