View Single Post
Old 12-05-2007, 03:04 PM   #4 (permalink)
Niceshot23
Registered User
 
Join Date: Oct 2004
Posts: 104
+0 Internets
going by what you wrote, id open the ini file and put it all into 1 string and manipulate it instead of actually using the readini function.... here's what i suggest

dim strText as string
dim intStart as long
dim intEnd as long
dim intRecords as int
dim intRecord as long
dim strname as string
dim stremail as string

'strtext should equal to the
strText = "[general]
totalrecords=3[list]
infoname1=Blahblah
infoemail1=blah@blah.com
infoname2=Mr.White
infoemail2=White@sad.com
infoname3=Mr. Black
infoemail3=black@mr.com"

intstart = instr(strtext, 1, "[general]")
intstart = instr(strtext, intstart, chr$(13))

'if it equals 0 then it means that this entry wasnt in the ini file
if intStart = 0 then exit sub

'now you should be at totalrecords= line
intstart = instr(strtext, intstart, "=")
intstart = intstart + 1

intend = instr(strtext, intstart, "[list]")

intrecords = mid(strtext, intstart, intend - intstart)

'now make a loop looking for "infoname1="
intrecord = 1
do until intstart = 0
'name
intstart = instr(strtext, intstart, "infoname")
intstart = instr(strtext, intstart, "=")
intstart = intstart + 1
intend = instr(strtext, intstart, chr$(13)
strname = mid(strtext, intstart, intend - intstart)

'email
intstart = instr(strtext, intstart, "infoemail")
intstart = instr(strtext, intstart, "=")
intstart = intstart + 1
intend = instr(strtext, intstart, chr$(13)
stremail = mid(strtext, intstart, intend - intstart)

'intrecord is the number of times it goes through this loop, meaning that there are that many "infoname"'s regardless of the number next to it
intrecord = intrecord + 1
loop

once you're complete, using all the numbers and strings you've grabbed, you should be able to create a new string and use that to overwrite the ini file ....


i havent ran this i just typed this out in the comments ... dont have vb at work but i've worked 6 years in vb so i know what im doing ... besides, im only going on what you've written ....
Niceshot23 is offline   Reply With Quote

 
Uberguilds Network