I am trying to make a text editor in VB. I have a text box on a form and a common dialog box. How do i get the file to open in that text box
Printable View
I am trying to make a text editor in VB. I have a text box on a form and a common dialog box. How do i get the file to open in that text box
Do a search for reading text files.
VB Code:
With CommonDialog1 .Filter = "Text Files|*.txt" .ShowOpen Open .FileName For Input As #1 Do While Not EOF(1) Input #1, line Text1.Text = Text1.Text & line & vbNewLine Loop Close #1 End With
Hope this helps..
Phreak
Thanks. Got it working
VB Code:
Dim intFile As Integer On Error GoTo No_Open intFile = FreeFile With cdlFiles .Filter = "Files(*.txt)|*.txt" .DefaultExt = "txt" .DialogTitle = "Open File" .Flags = cdlOFNFileMustExist + cdlOFNPathMustExist .ShowOpen End With Open cdlFiles.FileName For Input As intFile rtfPad.Text = Input(LOF(1), intFile) Close intFile Exit Sub No_Open: End Sub
Doesnt work for me:confused:
VB Code:
Public Sub OpenDocument() On Error GoTo No_Open dlgOpen.ShowOpen Open dlgOpen.FileName For Input As #1 Do While Not EOF(1) Input #1, Line txtMain.Text = txtMain.Text & Line & vbNewLine Loop Close #1 Exit Sub No_Open: Me.Refresh txtMain.SetFocus End Sub