|
-
Nov 21st, 1999, 07:22 PM
#1
Thread Starter
Hyperactive Member
Hi gang,
I have a INI file that I use to store registered users. The format is like this:
[Users]
user1=Name
user2=Name
user3=Name
user4=Name
and so on....
I use a loop to get all the names and loads them into a combo box.
Now here's the problem. I give the user a option to delete their name. I tried deleting the entire key (user2) and now my loop will stop at user1 and not read the rest of the names.
I can get the default string to come up as "user deleted" or even write that out to the ini file and it works fine, but I would prefer not to see that in the combo box.
I downloaded a zip file from Ken Whiteman and he has a routine to delete the null value. I don't quite understand it.
Could someone please give me some sort of example how I can do what I'm trying to do or if anyone has downloaded that example, could someone explain to me the logic behind it.
Sorry for the long post. Just wanted to be as clear as possible.
Thanks,
JazzBass
------------------
21 yr old beginner VB Programmer
VB 6 Professional @ Home
VB 3 Professional @ the Office
-
Nov 21st, 1999, 07:41 PM
#2
Lively Member
When you delete a user, instead of removing the entry, try changing the username to something like *DELETED*. When you load the values in to your combo box, add an if statement like
line input #1,tempstring
If not (instr(tempstring,"*DELETED*")) then
combo1.additem tempstring
end if
Hope this helps
Chris
-
Nov 21st, 1999, 08:29 PM
#3
Thread Starter
Hyperactive Member
Chris,
Thanks a lot. I understand what you mean. One question. Since I'm using the INI API's, I would put the code you suggested in my routine that includes the GetPrivateProfileString without the
'line input #1'. Is this correct or would I use that also?
Just making sure. 
Thanks again Chris,
JazzBass
If anyone has any other input, please don't hold back.
[This message has been edited by JazzBass (edited 11-22-1999).]
-
Nov 21st, 1999, 10:32 PM
#4
Thread Starter
Hyperactive Member
Hi gang,
I've been trying to figure out how to not show "Deleted" in my combo box but I haven't been successful. I'm trying what Chris suggested.
Here is my code to input all values from my ini file:
Code:
Dim lRet As Long
Dim strbuffer As String
Dim i As Integer
i = 1
Do
strbuffer = Space(255)
lRet = GetPrivateProfileString("Users", "user" & CStr(i), "", strbuffer, Len(strbuffer), "C:\MyFile.ini")
If lRet Then
user = strbuffer
cmbCheck.AddItem user
End If
i = i + 1
Loop While lRet > 0
end sub
What do I need to add to this code to not add "Deleted" to the combo box?
Please help.
Thanks,
JazzBass
------------------
21 yr old beginner VB Programmer
VB 6 Professional @ Home
VB 3 Professional @ the Office
-
Nov 21st, 1999, 10:46 PM
#5
Instead of deleting the value overwrite it with *deleted*.
------------------
Vincent van den Braken
EMail: [email protected]
ICQ: 15440110
Homepage: http://www.azzmodan.demon.nl
-
Nov 22nd, 1999, 12:22 PM
#6
Thread Starter
Hyperactive Member
Azzmodan,
Thanks. Yeah, that's what I've been doing, but if I can help it, I don't want to display "Deleted" in my combo box.
How can I delete a combo box value (Possible multiple occurances if more than one user is deleted) if I know what the string is, but don't know the list index?
Please keep the suggestions coming.
Thanks,
JazzBass
-
Nov 22nd, 1999, 12:26 PM
#7
Try:
Code:
Private Sub Command1_Click()
Dim lRet As Long
Dim sBuff As String * 255
Dim sUser As String
Dim I As Integer
While GetPrivateProfileString("Users", "user" & CStr(I + 1), "", sBuff, 255, "C:\MyFile.ini")
sUser = Left(sBuff, InStr(sBuff, Chr(0)) - 1)
If sUser <> "Deleted" Then cmbCheck.AddItem sUser
I = I + 1
Wend
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
Nov 22nd, 1999, 05:36 PM
#8
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|