VB School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB Expert!

Join 300,464 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,688 people online right now. Registration is fast and FREE... Join Now!




how to read the last 2 line of the text file

 

how to read the last 2 line of the text file

nitoy

1 Jul, 2009 - 10:11 PM
Post #1

New D.I.C Head
*

Joined: 1 Jul, 2009
Posts: 3

hi everybody!

i want to read the last 2 line of the text file, can someone help me how to do that? i need the code.

this is the text file content..

1,nest,password,1,seretr@yahoo.com,0,NitoyChar,,,,,,,,
0
2,daknest,seees,0,jx2ade@yahoo.com,0,,,,,,,,,
0
3,daknsest,sesdfs,0,asde@yahoo.com,0,,,,,,,,,
0


i want to read the integer before the "," in line before the last line for me to determine whats the next number should i write for the next data


User is offlineProfile CardPM
+Quote Post


firebolt

RE: How To Read The Last 2 Line Of The Text File

1 Jul, 2009 - 11:26 PM
Post #2

D.I.C Lover
Group Icon

Joined: 20 Feb, 2009
Posts: 5,463



Thanked: 75 times
Dream Kudos: 1675
My Contributions
Can we see what you have so far?
User is offlineProfile CardPM
+Quote Post

nitoy

RE: How To Read The Last 2 Line Of The Text File

2 Jul, 2009 - 01:09 AM
Post #3

New D.I.C Head
*

Joined: 1 Jul, 2009
Posts: 3

this my work, 1 cmdSave and 2 text box txtpass.text & txtpass and 2 otion for male or female.


CODE
Private Sub cmdSave_Click()

Dim sTemp As String
Dim nFile As Integer
Dim sex As Integer

If Option1.Value = True Then
    sex = 1
Else
    sex = 0
End If

  nFile = FreeFile()
  Open "c:\sample.txt" For Append As #nFile

  Print #nFile, "," & txtuser.Text & "," & txtpass.Text & "," & sex & "," & "email@blank.com,0,,,,,,,,,"
  Print #nFile, "0"
  Close #nFile
  
  MsgBox "User Saved"
End Sub


and this is what inside the text file...

1,nitoy,biodse,1,email@blank.com,0,,,,,,,,,
0
2,darknest,bimasdae,0,email@blank.com,0,,,,,,,,,
0
3,dasest,bimasae,0,email@blank.com,0,,,,,,,,,
0


my problem is how to read the number of the last user inserted for me to add the number for the new user to add in the text file


Attached thumbnail(s)
Attached Image
User is offlineProfile CardPM
+Quote Post

NoBrain

RE: How To Read The Last 2 Line Of The Text File

2 Jul, 2009 - 03:43 AM
Post #4

D.I.C Lover
Group Icon

Joined: 25 Mar, 2009
Posts: 1,152



Thanked: 33 times
Dream Kudos: 125
My Contributions
you can track how many vbCrLf is in your txt file and then you will know who is your last 2 rows
User is offlineProfile CardPM
+Quote Post

nitoy

RE: How To Read The Last 2 Line Of The Text File

2 Jul, 2009 - 08:35 PM
Post #5

New D.I.C Head
*

Joined: 1 Jul, 2009
Posts: 3

firebolt can you help me build the code i need?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 02:29AM

Live VB Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month