Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Open

yodevoyoyodevoyo Member Posts: 15
[b][red]This message was edited by yodevoyo at 2003-11-12 15:3:53[/red][/b][hr]
[code]Private Sub mnuFileOpen_Click()
On Error GoTo DialogError
With open1
.CancelError = True
.Filter = "Text Documents (*.txt)|*.txt"
.FilterIndex = 1
.DialogTitle = "Open"
.ShowOpen
[b]Open .FileName For Input As 2
Show 2, rftText.Text
Close 2[/b]
End With
DialogError:
End Sub
[/code]

The bolded part above is where I know the problem is but i can't figure it out. If you can help please do so.

Thanks,

Devo


Comments

  • the walrusthe walrus Member Posts: 249
    [b][red]This message was edited by the walrus at 2003-11-12 20:43:48[/red][/b][hr]
    Corrections in [blue]blue[/blue]

    [code]
    Private Sub mnuFileOpen_Click()
    [blue]Dim getLine as String[/blue]
    On Error GoTo DialogError
    With open1
    .CancelError = True
    .Filter = "Text Documents (*.txt)|*.txt"
    .FilterIndex = 1
    .DialogTitle = "Open"
    .ShowOpen
    [b] Open .FileName For Input As [blue]#[/blue]2
    [blue] rtfText.Text = ""
    Do Until EOF(2)
    Line Input #2, getLine
    rtfText.Text = rtfText.Text + getLine + vbCrLf
    Loop[/blue]
    Close [blue]#[/blue]2[/b]
    End With
    DialogError:
    End Sub
    [/code]

    Is your rtfTextBox called rftText or rtfText? You had rftText typed in, but I changed it to rtfText... You may need to change my code; I assumed it was a typo. You may not [italic]need[/italic] then [blue]#[/blue] signs, but that's just how it's done, so I stuck them in there.




  • Gaya3Gaya3 Member Posts: 59
    try this too..


    Private Sub mnuFileOpen_Click()
    On Error GoTo DialogError
    With open1
    .CancelError = True
    .Filter = "Text Documents (*.txt)|*.txt"
    .FilterIndex = 1
    .DialogTitle = "Open"
    .ShowOpen
    Open .FileName For Input As #2
    rftText.Text = ""
    [b]rftText.FileName = .FileName[/b]
    Close #2
    End With
    DialogError:
    Close #2
    End Sub
  • kel1981bkel1981b Member Posts: 852
    : try this too..
    :
    :
    : Private Sub mnuFileOpen_Click()
    : On Error GoTo DialogError
    : With open1
    : .CancelError = True
    : .Filter = "Text Documents (*.txt)|*.txt"
    : .FilterIndex = 1
    : .DialogTitle = "Open"
    : .ShowOpen
    : Open .FileName For Input As #2
    : rftText.Text = ""
    : [b]rftText.FileName = .FileName[/b]
    : Close #2
    : End With
    : DialogError:
    : Close #2
    : End Sub
    :

    [blue]Using RichText box LoadFile method you don't need to use Open statement[/blue]
    [code]
    Private Sub mnuFileOpen_Click()
    On Error GoTo DialogError
    With open1
    .CancelError = True
    .Filter = "Text Documents (*.txt)|*.txt"
    .FilterIndex = 1
    .DialogTitle = "Open"
    .ShowOpen
    [b]rftText.LoadFile = .FileName[/b]
    Close #2
    End With
    [/code]

  • yodevoyoyodevoyo Member Posts: 15
    : : try this too..
    : :
    : :
    : : Private Sub mnuFileOpen_Click()
    : : On Error GoTo DialogError
    : : With open1
    : : .CancelError = True
    : : .Filter = "Text Documents (*.txt)|*.txt"
    : : .FilterIndex = 1
    : : .DialogTitle = "Open"
    : : .ShowOpen
    : : Open .FileName For Input As #2
    : : rftText.Text = ""
    : : [b]rftText.FileName = .FileName[/b]
    : : Close #2
    : : End With
    : : DialogError:
    : : Close #2
    : : End Sub
    : :
    :
    : [blue]Using RichText box LoadFile method you don't need to use Open statement[/blue]
    : [code]
    : Private Sub mnuFileOpen_Click()
    : On Error GoTo DialogError
    : With open1
    : .CancelError = True
    : .Filter = "Text Documents (*.txt)|*.txt"
    : .FilterIndex = 1
    : .DialogTitle = "Open"
    : .ShowOpen
    : [b]rftText.LoadFile = .FileName[/b]
    : Close #2
    : End With
    : [/code]
    :
    :
    None of these work I would click open and it still would just be blank instead of opening the file.
  • KDivad LeahcimKDivad Leahcim Member Posts: 3,948
    : You may not [italic]need[/italic] then [blue]#[/blue] signs, but that's just how it's done, so I stuck them in there.
    :

    For Close and Open, no. For Line Input, I think yes. For Write, I also think yes. For Print, it's syntactically correct to use or withhold the # sign. However, no # sign causes it to print (the number and text) to the form in which the code runs, whereas a # will cause it to print to the text to the file indicated by the number. Lots of fun, eh?
  • kel1981bkel1981b Member Posts: 852
    : : : try this too..
    : : :
    : : :
    : : : Private Sub mnuFileOpen_Click()
    : : : On Error GoTo DialogError
    : : : With open1
    : : : .CancelError = True
    : : : .Filter = "Text Documents (*.txt)|*.txt"
    : : : .FilterIndex = 1
    : : : .DialogTitle = "Open"
    : : : .ShowOpen
    : : : Open .FileName For Input As #2
    : : : rftText.Text = ""
    : : : [b]rftText.FileName = .FileName[/b]
    : : : Close #2
    : : : End With
    : : : DialogError:
    : : : Close #2
    : : : End Sub
    : : :
    : :
    : : [blue]Using RichText box LoadFile method you don't need to use Open statement[/blue]
    : : [code]
    : : Private Sub mnuFileOpen_Click()
    : : On Error GoTo DialogError
    : : With open1
    : : .CancelError = True
    : : .Filter = "Text Documents (*.txt)|*.txt"
    : : .FilterIndex = 1
    : : .DialogTitle = "Open"
    : : .ShowOpen
    : : [b]rftText.LoadFile = .FileName[/b]
    : : Close #2
    : : End With
    : : [/code]
    : :
    : :
    : None of these work I would click open and it still would just be blank instead of opening the file.
    :
    I do not know why it did not work. The following code
    [code]
    With open1

    .CancelError = True
    .Filter = "Text Documents (*.txt)|*.txt"
    .FilterIndex = 1
    .DialogTitle = "Open"
    .ShowOpen
    rftText.LoadFile .FileName

    End With
    [/code] works perfectrly on mine machine. Make sure when you select file (click ones on file) from list of files the file name appears in File name Textbox. When it's OK, click Open button. You can also double click on file in list.
Sign In or Register to comment.