Computing.Net > Forums > Programming > VB6 raf help needed

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

VB6 raf help needed

Reply to Message Icon

Name: JessicaQ
Date: February 10, 2007 at 07:15:08 Pacific
OS: XP home
CPU/Ram: no clue/256
Product: home built
Comment:

When my program starts, there is a listbox with 43 names in it. When user clicks on a name, variable CurNum is remembered(CurNum = List1.ListIndex + 1), form2 loads, and opens a raf to CurNum record, and user can fill info about person into textboxes and save the info,So far so good.
Now here's my problem, say :

CurNum 30=Mike, New York
CurNum 31=Doug, Florida
CurNum 32=Steve, Indiana
CurNum 33=Joey, Ohio

And 31 Doug didn't send me a Valentine's Day card, so I want to delete him.(LOL)

Now 31 Doug deletes okay, but afterwards
32 becomes blank and 33 becomes Indiana, 34 becomes Ohio, all down the list. And I can't see my mistake.
Any ideas appreciated

Public Sub DeleteMemberFromAddyInfo()
Dim DirResult
Dim tmpAddyFileNum As Integer
Dim tmpAddy As AddressList
Dim tmpAddyListLen As Long
''''''''''''''''''''''''''''''''
If Dir("AddyInfo.TMP") = "AddyInfo.TMP" Then
Kill "AddyInfo.TMP"
End If
''calculate length of record
tmpAddyListLen = Len(tmpAddy)
''create tmp file
tmpAddyFileNum = FreeFile
Open gPath & "AddyInfo.TMP" For Random As tmpAddyFileNum Len = tmpAddyListLen
''what record are we at?
''curnum...so.....
''how many recs in ginfo?
gAddressListLen = Len(gInfo)
Dim TotalOld
TotalOld = FileLen(gPath & "AddyInfo.DAT") /
gAddressListLen
Dim times
For times = 1 To TotalOld
If times <> CurNum Then
Get #gAddyFileNumber, times, gInfo
Put #tmpAddyFileNum, times, gInfo
End If
Next times
Close
Kill gPath & "AddyInfo.DAT"
Name gPath & "AddyInfo.TMP" As gPath & "AddyInfo.DAT"

End Sub

Thanks, Jessica



Sponsored Link
Ads by Google

Response Number 1
Name: Chi Happens
Date: February 13, 2007 at 07:37:37 Pacific
Reply:

wow, I suggest using either a database file (such as access) or an XML file that way you don't have to do what you are doing (making a temp file and then moving names into dat file).

Or, you could simply use a collection class that you could simply save to the disk whenever something changes in it.

Chi

They mostly come at night...mostly.


0
Reply to Message Icon

Related Posts

See More


Need Solution for accessi... Cannot install VB Express...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VB6 raf help needed

VB6 Array help needed www.computing.net/answers/programming/vb6-array-help-needed/1883.html

C++ vs Pascal help needed www.computing.net/answers/programming/c-vs-pascal-help-needed/11150.html

VB6 cmd button needed www.computing.net/answers/programming/vb6-cmd-button-needed/1274.html