School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
Welcome to Dream.In.Code
Become an Expert!

Join 340,154 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 3,961 people online right now. Registration is fast and FREE... Join Now!



Rich Text Box trouble

Page 1 of 1

Rich Text Box trouble Formatting i think.... Rate Topic: -----

#1 SoloFrog  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 20-April 09


Dream Kudos: 0

Post icon  Posted 20 April 2009 - 07:01 PM

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.
 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.

{\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.
Was This Post Helpful? 0
  • +
  • -


#2 firebolt  Icon User is offline

  • D.I.C Lover
  • Icon
  • View blog
  • Group: Author w/DIC++
  • Posts: 5,555
  • Joined: 20-February 09


Dream Kudos: 1675

Posted 20 April 2009 - 07:17 PM

Edit: Post was a VB6.

This post has been edited by firebolt: 20 April 2009 - 07:40 PM

Was This Post Helpful? 0
  • +
  • -

#3 SoloFrog  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 20-April 09


Dream Kudos: 0

Posted 20 April 2009 - 07:31 PM

Anyways... back on the ranch

If anyone could help that would be awsome.
Was This Post Helpful? 0
  • +
  • -

#4 Core  Icon User is online

  • Jasper
  • Icon
  • View blog
  • Group: Admins
  • Posts: 3,480
  • Joined: 08-December 08


Dream Kudos: 975

Expert In: .NET Framework

Posted 20 April 2009 - 07:38 PM

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)?
Was This Post Helpful? 0
  • +
  • -

#5 PsychoCoder  Icon User is offline

  • apt-get install DIC.bin
  • Icon
  • View blog
  • Group: Admins
  • Posts: 16,214
  • Joined: 26-July 07


Dream Kudos: 12400

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

Posted 20 April 2009 - 07:56 PM

@SoloFrog: Try this

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?
Was This Post Helpful? 0
  • +
  • -

#6 SoloFrog  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 20-April 09


Dream Kudos: 0

Posted 20 April 2009 - 08:42 PM

@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 :(


Thanks guys for speedy responses :)
Was This Post Helpful? 0
  • +
  • -

#7 PsychoCoder  Icon User is offline

  • apt-get install DIC.bin
  • Icon
  • View blog
  • Group: Admins
  • Posts: 16,214
  • Joined: 26-July 07


Dream Kudos: 12400

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

Posted 20 April 2009 - 08:58 PM

@SoloFrog: So you're trying to put an image in a RichTextBox?
Was This Post Helpful? 0
  • +
  • -

#8 SoloFrog  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 20-April 09


Dream Kudos: 0

Posted 21 April 2009 - 06:43 AM

@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?
Was This Post Helpful? 0
  • +
  • -

#9 SoloFrog  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 20-April 09


Dream Kudos: 0

Posted 21 April 2009 - 08:37 AM

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?
Was This Post Helpful? 0
  • +
  • -

#10 SoloFrog  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 20-April 09


Dream Kudos: 0

Posted 21 April 2009 - 06:56 PM

Following some advice from a teacher out at the college i mixed my code up and came up with this
 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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1


Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Live Help!

Be Social

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

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month