Results 1 to 3 of 3

Thread: Opening a file for read and write.

  1. #1

    Thread Starter
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    Hi, can you help me with this code?
    I want to load the contents of the file into a text box for editing by the user, but for some reason, the file doesn't show up in the text dialog. Heres what i've got:
    Code:
    Dim sFile
    Dim sA
     'Prompt user for filename
        CD1.DialogTitle = "Secure-It!"
        CD1.Flags = cdlOFNHideReadOnly
        CD1.Filter = "HTML Files|*.htm;*.html|Text Files|*.txt|All files (*.*)|*.*"
        CD1.CancelError = True
        On Error Resume Next
        CD1.ShowOpen
        'Grab filename
        sFile = CD1.FileName
        If Err = 0 Then
        On Error Resume Next
        Open sFile For Random As #1
        Print #1, sA
        Close #1
        End If
        txtCode = sA
        frmMain.Caption = "PageGen Unlimited - " & sFile

  2. #2
    Guest
    Try:

    Code:
    On Error Resume Next
    Dim sFile
    Dim sA
     'Prompt user for filename
        CD1.DialogTitle = "Secure-It!"
        CD1.Flags = cdlOFNHideReadOnly
        CD1.Filter = "HTML Files|*.htm;*.html|Text Files|*.txt|All files (*.*)|*.*"
        CD1.CancelError = True
        On Error Resume Next
        CD1.ShowOpen
        'Grab filename
        sFile = CD1.FileName
        If Err = 0 Then
        Open sFile For Output As #1
        Print #1, sA
        Close #1
        End If
        txtCode = sA
        frmMain.Caption = "PageGen Unlimited - " & sFile

  3. #3
    Member
    Join Date
    Jun 2000
    Location
    Earth, Milky Way Galaxy (Take a left turn near our Sun and ask for directions at your nearest space port, just ask for Dax.)
    Posts
    35

    Talking You made a small mistake

    Hi use this code:

    Dim sFile
    Dim sA As String
    'Prompt user for filename
    CD1.DialogTitle = "Secure-It!"
    CD1.Flags = cdlOFNHideReadOnly
    CD1.Filter = "HTML Files|*.htm;*.html|Text Files|*.txt|All files (*.*)|*.*"
    CD1.CancelError = True
    On Error Resume Next
    CD1.ShowOpen
    'Grab filename
    sFile = CD1.FileName
    If Err = 0 Then
    On Error Resume Next
    Open sFile For Random As #1
    Do Until EOF(#1)
    Line Input #1, sA
    txtCode.Text = txtCode.Text & vbcrlf & sA
    Loop
    Close #1
    End If
    frmMain.Caption = "PageGen Unlimited - " & sFile


    'Hope this will do

    Dax Pandhi
    CEO, Nukeation Labs
    www.nukeation.com
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width