Jump to content

[Resolvido] Richtextbox não aceita acentos ?


leo2012
 Share

Recommended Posts

Como eu faço pro meu Richtextbox aceitar acentos? olha o código que eu tenho até agora:

RichTextBox1.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)

Mas isso só lê o arquivo,e nao reconhece os acentos

Edited by ribeiro55
Link to comment
Share on other sites

http://wiki.portugal-a-programar.pt/dev_net:vb.net:stream_readers_writers#porque_razao_nao_e_possivel_ler_caracteres_especiais_como_acentos

Esse ReadAllText é uma implementação "straightforward", para casos menos específicos.

Experimenta com um StreamReader, como se demonstra no artigo.

Sérgio Ribeiro


"Great coders aren't born. They're compiled and released"
"Expert coders do not need a keyboard. They just throw magnets at the RAM chips"

Link to comment
Share on other sites

Nao consegui :/ tentei esse código,mas ele só exibe a primeira linha do documento

Dim SR As New IO.StreamReader(OpenFileDialog1.FileName, System.Text.Encoding.Default)
 While Not SR.EndOfStream
	 RichTextBox1.Text = SR.ReadLine
 End While
 SR.Close()
Edited by ribeiro55
Link to comment
Share on other sites

Consegui,olha,vou postar o código pra quem estiver com o mesmo problema, O ReadLine,estava impedindo a leitura de todas as linhas,entao coloquei ReadEnd,assim ele le o arquivo ate o final 👍

Dim SR As New IO.StreamReader(OpenFileDialog1.FileName, System.Text.Encoding.Default)
 RichTextBox1.Text = SR.ReadToEnd
Edited by ribeiro55
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.