andycharger Posted April 2, 2003 Posted April 2, 2003 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 Quote
*Experts* Volte Posted April 2, 2003 *Experts* Posted April 2, 2003 That depends.. how are you reading from your INI file? Post code please. Quote
andycharger Posted April 2, 2003 Author Posted April 2, 2003 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 Quote
*Experts* Volte Posted April 3, 2003 *Experts* Posted April 3, 2003 Well, I suppose it's possible that your buffer is a bit too large. Try doing it like this: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. Quote
*Experts* Volte Posted April 3, 2003 *Experts* Posted April 3, 2003 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. Quote
Recommended Posts