VB5: Deleting records from a (text) data base? 
Author Message
 VB5: Deleting records from a (text) data base?

Can someone tell me where I am going wrong here
(I am using the data OCX that ships with VB5):
-------------------snip--------------------------------
Private Sub cmdDelete_Click()
  'this may produce an error if you delete the last
  'record or the only record in the recordset
Data1.Enabled = False
RecordSource
Dim SSN As String
Dim Linebuffer As String
Dim Match As String
txtFields(0).Text = SSN
Open "C:\DEPO\Depo.txt" For Input As #1
Open "C:\DEPO\Depo.tmp" For Output As #2
Do Until EOF(1)
NextSSN:
Line Input #1, Linebuffer
Match = Left(Linebuffer, 9)
If SSN = Match Then
GoTo NextSSN
Else
Print #2, Linebuffer
End If
Loop
Close #1
Close #2
Kill "C:\DEPO\Depo.txt"
Name "C:\DEPO\Depo.tmp" As "C:\DEPO\Depo.txt"
Data1.RecordSource = "Depo#txt"
End Sub
-------------------------snip-----------------------------------
Any and all help will be appreciated!!!!
Cliff

--
****************************************
NOTICE TO BULK EMAILER(S):
Pursuant to US Code, Title 47, Chapter
5, Subchapter II, 227, any & all
unsolicited commercial e-mail sent to
this address is subject to a download
and archival fee in the amount of
$500 US and copies will be forwarded
to domain administrators--E-mailing
denotes acceptance of said terms!
****************************************

  vcard.vcf
< 1K Download


Thu, 03 Aug 2000 03:00:00 GMT  
 VB5: Deleting records from a (text) data base?

I am having a hard time following this concept, all though the portion that is giving you a problem is easily fixed.  You have the classic never use a Goto problem,  you have short circuited the loop check by using a goto, you have already reached the end of the file but didn't check for it before trying to read the next data element.  I am real confused as to where the data control is used and why, these just look like text files to me.

Do
    line Input #1, Linebuffer
    If SSN  <>  Left(Linebuffer, 9 )  Then
      Print #2, Linebuffer
    end if
Loop Until EOF(1)

Can someone tell me where I am going wrong here
    (I am using the data OCX that ships with VB5):
    -------------------snip--------------------------------
    Private Sub cmdDelete_Click()
      'this may produce an error if you delete the last
      'record or the only record in the recordset
    Data1.Enabled = False
    RecordSource
    Dim SSN As String
    Dim Linebuffer As String
    Dim Match As String
    txtFields(0).Text = SSN
    Open "C:\DEPO\Depo.txt" For Input As #1
    Open "C:\DEPO\Depo.tmp" For Output As #2
    Do Until EOF(1)
        line Input #1, Linebuffer
       If SSN = Left(Linebuffer, 9 )  Then
        Else
             Print #2, Linebuffer
        End If
    Loop
    Close #1
    Close #2
    Kill "C:\DEPO\Depo.txt"
    Name "C:\DEPO\Depo.tmp" As "C:\DEPO\Depo.txt"
    Data1.RecordSource = "Depo#txt"
    End Sub
    -------------------------snip-----------------------------------
    Any and all help will be appreciated!!!!
    Cliff

    --
    ****************************************
    NOTICE TO BULK EMAILER(S):
    Pursuant to US Code, Title 47, Chapter
    5, Subchapter II, 227, any & all
    unsolicited commercial e-mail sent to
    this address is subject to a download
    and archival fee in the amount of
    $500 US and copies will be forwarded
    to domain administrators--E-mailing
    denotes acceptance of said terms!
    ****************************************



Thu, 03 Aug 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Deleting records from one table based on data from another

2. VB5: Deleting records using a text Dbase file...

3. Deleted records when text file is linked as table (#deleted)

4. Deleting Records based on Input box

5. VB6 - Deleting Records based in AND condition is not working correctly

6. Delete range of paragraphs based on start text of paragraphs

7. Delete text based on STYLE??

8. vb5 displays a record on screen but prints data from another record

9. searching for records based on entered text

10. How do I select records based on a value typed into a text box

11. Problem accessing record from SQL Data base Date/Time Field

12. Help: converting VB3 binary text based program to to VB5 database

 

 
Powered by phpBB® Forum Software