|
-
Aug 25th, 2009, 02:02 AM
#1
Thread Starter
Addicted Member
how to use this public sub
i am starting to get the hang of vb6, but are stuck trying to use this public sub in a class from a form. I am trying to search for a key. i have been able to save to the ini file, but do not know how to use this:
Code:
Public Sub EnumerateCurrentSection(ByRef sKey() As String, ByRef iCount As Long)
Dim sSection As String
Dim iPos As Long
Dim iNextPos As Long
Dim sCur As String
iCount = 0
Erase sKey
sSection = INISection
If (Len(sSection) > 0) Then
iPos = 1
iNextPos = InStr(iPos, sSection, Chr$(0))
Do While iNextPos <> 0
sCur = Mid$(sSection, iPos, (iNextPos - iPos))
If (sCur <> Chr$(0)) Then
iCount = iCount + 1
ReDim Preserve sKey(1 To iCount) As String
sKey(iCount) = Mid$(sSection, iPos, (iNextPos - iPos))
iPos = iNextPos + 1
iNextPos = InStr(iPos, sSection, Chr$(0))
End If
Loop
End If
End Sub
-
Aug 25th, 2009, 07:42 AM
#2
Re: how to use this public sub
That sub looks like part of a module or class. Can't really answer your question because that sub depends on some other information. The INISection variable for example appears to be a module-level or public variable that is populated elsewhere.
I also think that the code may be used for a custom INI file. I say that because the code is looking for Chr$(0) as a delimiter where [ ] symbols would be expected. But of course those could have been replaced with Chr$(0) elsewhere in the original code. Otherwise, you'd have to know the structure of the custom INI to guarantee you understand the routine. And if using APIs to read/write INIs, you don't need manual parsing routines.
-
Aug 25th, 2009, 01:07 PM
#3
Re: how to use this public sub
i am using the same ini class I use it like this to get all the keys in a section:
Code:
Public Sub EnumerateCurrentSection(ByRef sKey() As String, ByRef iCount As Long)
Dim sSection As String
Dim iPos As Long
Dim iNextPos As Long
Dim sCur As String
iCount = 0
Erase sKey
sSection = INISection
If (Len(sSection) > 0) Then
iPos = 1
iNextPos = InStr(iPos, sSection, Chr$(0))
Do While iNextPos <> 0
sCur = Mid$(sSection, iPos, (iNextPos - iPos))
If (sCur <> Chr$(0)) Then
iCount = iCount + 1
ReDim Preserve sKey(1 To iCount) As String
sKey(iCount) = Mid$(sSection, iPos, (iNextPos - iPos))
iPos = iNextPos + 1
iNextPos = InStr(iPos, sSection, Chr$(0))
End If
Loop
End If
End Sub
Last edited by isnoend07; Aug 25th, 2009 at 01:10 PM.
Reason: posted wrong code
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Aug 25th, 2009, 02:46 PM
#4
Re: how to use this public sub
The class also contains this to put the section titles in a combo box
Code:
Private Sub FillTemplatesInCombo()
Dim asSections() As String, lNoofSections As Long, lIndex As Long
clsINIFile.EnumerateAllSections asSections, lNoofSections
CboTemplates.Clear
For lIndex = 1 To lNoofSections
CboTemplates.AddItem asSections(lIndex)
Next lIndex
End Sub
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
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
|