Skip to content

Commit bfd815c

Browse files
committed
Enhancement and fix
1 parent 5915f25 commit bfd815c

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

Common.vb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
' C:\
99
' C:\Project\
1010

11-
Dim sPath As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)
12-
13-
If Right(sPath, 1) <> "\" Then
14-
sPath = sPath & "\"
15-
End If
16-
17-
Return sPath
11+
Return AppDomain.CurrentDomain.BaseDirectory
1812
End Function
1913
End Module

IniFile.vb

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ Public Class IniFile
3434
Return False
3535
End If
3636

37-
fs = New FileStream(m_sPathFileName, FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read)
37+
fs = New FileStream(m_sPathFileName, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite)
3838
sr = New StreamReader(fs, Encoding.UTF8)
3939

4040
While True
41-
sLine = sr.ReadLine()
41+
sLine = Trim(sr.ReadLine())
4242

4343
m_nItemsCount = m_nItemsCount + 1
4444

@@ -98,7 +98,7 @@ Public Class IniFile
9898
Next
9999

100100

101-
fs = New FileStream(m_sPathFileName, FileMode.Create, FileAccess.Write, FileShare.None)
101+
fs = New FileStream(m_sPathFileName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)
102102
sw = New StreamWriter(fs, Encoding.UTF8)
103103

104104
sw.Write(sWrite)
@@ -145,9 +145,7 @@ Public Class IniFile
145145
nPos = InStr(sRetVal, "=")
146146

147147
If (nPos > 0) Then
148-
sRetVal = sRetVal.Substring(nPos)
149-
Else
150-
148+
sRetVal = Trim(sRetVal.Substring(nPos))
151149
End If
152150

153151
Return sRetVal
@@ -157,6 +155,7 @@ Public Class IniFile
157155
Dim nIndex As Integer
158156

159157
Key = Trim(Key)
158+
value = Trim(value)
160159

161160
If Key = "" Then
162161
Err.Raise(INIFILE_ERR_KEY_REQUIRED, , "Missing key parameter")
@@ -179,17 +178,29 @@ Public Class IniFile
179178

180179
Private Function _GetIndex(ByVal Key As String) As Int32
181180
Dim i As Integer
182-
Dim sSearchKey As String
181+
Dim sItem As String
182+
Dim sCheckKey As String
183183
Dim nPos As Int32
184184

185-
sSearchKey = Key & "=" '-- "key="
185+
186+
Key = LCase(Key)
186187

187188
For i = 1 To m_nItemsCount
188-
nPos = InStr(LTrim(m_aItems(i - 1)), sSearchKey, CompareMethod.Text)
189+
sItem = m_aItems(i - 1)
190+
191+
If Left(sItem, 1) <> ";" Then '-- Ignore remark char ";"
192+
nPos = InStr(sItem, "=") '-- Find "=" char
193+
194+
If nPos > 0 Then
195+
'-- Get Key
196+
sCheckKey = Trim(LCase(Left(m_aItems(i - 1), nPos - 1)))
197+
198+
If sCheckKey = Key Then
199+
'-- Return actual array index (zero based array)
200+
Return (i - 1)
201+
End If
202+
End If
189203

190-
If nPos = 1 Then
191-
'-- Return actual array index (zero based array)
192-
Return (i - 1)
193204
End If
194205
Next
195206

My Project/AssemblyInfo.vb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Imports System.Runtime.InteropServices
1818
<Assembly: ComVisible(False)>
1919

2020
'The following GUID is for the ID of the typelib if this project is exposed to COM
21-
<Assembly: Guid("9ed892fc-cac2-4cfb-b1f1-2fa2da9f0da8")>
21+
<Assembly: Guid("9ed892fc-cac2-4cfb-b1f1-2fa2da9f0da8")>
2222

2323
' Version information for an assembly consists of the following four values:
2424
'
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' by using the '*' as shown below:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("1.1.0.0")>
35-
<Assembly: AssemblyFileVersion("1.1.0.0")>
34+
<Assembly: AssemblyVersion("1.2.0.0")>
35+
<Assembly: AssemblyFileVersion("1.2.0.0")>

0 commit comments

Comments
 (0)