VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 300,288 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,062 people online right now. Registration is fast and FREE... Join Now!




Rich Text Box trouble

 

Rich Text Box trouble, Formatting i think....

SoloFrog

20 Apr, 2009 - 07:01 PM
Post #1

New D.I.C Head
*

Joined: 20 Apr, 2009
Posts: 13


My Contributions
Ok so im designing a program that will read from various text files (preferably RTF files) and then put them into the RTF box in the program when a button is clicked.
Here is the portion of my code that i am referring to.
CODE
Try
            Dim fileText As String = My.Computer.FileSystem.ReadAllText("c:\" & selectedHero & ".rtf")


            infoDisplay.AppendText(fileText)
            infoDisplay.Rtf.Format()


        Catch
            MsgBox("Selected Hero currently has no File with us.")
        End Try


Now heres the problem. In the file i have a few pictures and its formatted and what not. I thought since its a RTF file and the Box is RTF it would auto format.... but anyways. It appears like this in the RTF Box.
CODE


{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20{\object\objemb{\*\objclass Paint.Picture}\objw3000\objh3000{\*\objdata
01050000
02000000
07000000
50427275736800
00000000
00000000
00d50100
424df6d40100000000003600000028000000c8000000c80000000100180000000000c0d4010000
000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff


Ok so im not sure how i can read from a RTF file and put it in the RTF box with the right format.... any ideas? Ive been searching around for a while.


User is offlineProfile CardPM
+Quote Post


firebolt

RE: Rich Text Box Trouble

20 Apr, 2009 - 07:17 PM
Post #2

D.I.C Lover
Group Icon

Joined: 20 Feb, 2009
Posts: 5,462



Thanked: 75 times
Dream Kudos: 1675
My Contributions
Edit: Post was a VB6.

This post has been edited by firebolt: 20 Apr, 2009 - 07:40 PM
User is offlineProfile CardPM
+Quote Post

SoloFrog

RE: Rich Text Box Trouble

20 Apr, 2009 - 07:31 PM
Post #3

New D.I.C Head
*

Joined: 20 Apr, 2009
Posts: 13


My Contributions
Anyways... back on the ranch

If anyone could help that would be awsome.
User is offlineProfile CardPM
+Quote Post

Core

RE: Rich Text Box Trouble

20 Apr, 2009 - 07:38 PM
Post #4

Den The Developer
Group Icon

Joined: 8 Dec, 2008
Posts: 2,943



Thanked: 213 times
Dream Kudos: 900
Expert In: C#, VB.NET, .NET Framework

My Contributions
Moved to VB.NET.

@ firebolt SoloFrog used the correct syntax to show the message box. If you are using MsgBox instead of MessageBox.Show, parantheses are required.

@ SoloFrog What exactly is wrong with the formatting? Is it displayed in the wrong order (layout problems) or doesn't correctly display the formatting (for example, no pictures)?
User is online!Profile CardPM
+Quote Post

PsychoCoder

RE: Rich Text Box Trouble

20 Apr, 2009 - 07:56 PM
Post #5

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,700



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
@SoloFrog: Try this

CODE

Try
            Dim fileText As String = My.Computer.FileSystem.ReadAllText("c:\" & selectedHero & ".rtf")

            infoDisplay.Rtf= fileText
            Dim s As String = infoDisplay.Text
            infoDisplay.AppendText(s)


        Catch
            MsgBox("Selected Hero currently has no File with us.")
        End Try


That should remove the RTF formatting?
User is offlineProfile CardPM
+Quote Post

SoloFrog

RE: Rich Text Box Trouble

20 Apr, 2009 - 08:42 PM
Post #6

New D.I.C Head
*

Joined: 20 Apr, 2009
Posts: 13


My Contributions
@Core
Basically my code is outputting that second box in the RTF box. All that code there is supposed to be a simple picture, but its not formatting it basically.

@PsychoCoder
I tried that and to no prevail sad.gif


Thanks guys for speedy responses smile.gif
User is offlineProfile CardPM
+Quote Post

PsychoCoder

RE: Rich Text Box Trouble

20 Apr, 2009 - 08:58 PM
Post #7

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,700



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
@SoloFrog: So you're trying to put an image in a RichTextBox?
User is offlineProfile CardPM
+Quote Post

SoloFrog

RE: Rich Text Box Trouble

21 Apr, 2009 - 06:43 AM
Post #8

New D.I.C Head
*

Joined: 20 Apr, 2009
Posts: 13


My Contributions
@PsychoCoder No, well im trying to read from a RTF file that HAS a image in it, and then when i put the said file and its content into a Visual Basic RTF Box, all it does is show that code instead of the picture. How can i get it to hide the formatting?


User is offlineProfile CardPM
+Quote Post

SoloFrog

RE: Rich Text Box Trouble

21 Apr, 2009 - 08:37 AM
Post #9

New D.I.C Head
*

Joined: 20 Apr, 2009
Posts: 13


My Contributions
Like i just dont see why a RTF Box in VB would not be able to use the formatting of a RTF file.... or maybe im missing something or some option?
User is offlineProfile CardPM
+Quote Post

SoloFrog

RE: Rich Text Box Trouble

21 Apr, 2009 - 06:56 PM
Post #10

New D.I.C Head
*

Joined: 20 Apr, 2009
Posts: 13


My Contributions
Following some advice from a teacher out at the college i mixed my code up and came up with this
CODE

Try
            Dim FileDB As New OpenFileDialog()
            FileDB.Filter = "All Files|*.*|RTF FILES|*.rtf"

            FileDB.FilterIndex = 2
            FileDB.InitialDirectory = "C:\"

            infoDisplay.LoadFile(FileDB.FileName)



        Catch
            MsgBox("Selected Hero currently has no File with us.")
        End Try

Still doing the same thing. It must be some kind of format option or something to do with the actual text box that im missing. If anyone has any ideas. Let me know.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 12:15PM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month