ini problem????

andycharger

Well-known member
Joined
Apr 2, 2003
Messages
152
My ini is returning a string value to my VB application but it is bringing it back with a square block on the end of the string.
It is an db path like this "C:\irs\irs1.mdb"
trouble is it has the square symbol at th eend of it.
Anyone know a way to stop the square coming back with the string?

Andy
 
That depends.. how are you reading from your INI file? Post code please.
 
Dim strCon As String
Dim sString As String
Dim lSize As Long
Dim lReturn As Long

Dim sNull As String
sString = String$(16, "*")
lSize = Len(sString)


lReturn = GetPrivateProfileString("irsconnection", "irsconn", "", sString, lSize, sFile)
strCon = sString
Connect.ConStr = strCon
 
Well, I suppose its possible that your buffer is a bit too large. Try
doing it like this:
Code:
Dim lSize As Long
Dim sString As String = New String(" ", 300) create the buffer; this is a better way than String$

lSize = GetPrivateProfileString("irsconnection", "irsconn", "", sString, 300, sFile)
sString = sString.SubString(0, lSize)
That dynamically gets the required size, rather than fixing it in one
spot.

Also, you should not use String$, as it is a VB6 compatability function
and is not CLR compliant.
 
Also, instead of using INI files, I would recommend using XML files
instead, as .NET has native support for them. Read in the MSDN about the System.Xml namespace.
 
Back
Top