|
-
Jul 11th, 2001, 01:26 PM
#1
Thread Starter
Addicted Member
GetPrivateProfileString - Removing '0' character from string
I'm using the GetPrivateProfileString API and I just realised it was causing an error to mycode. I used the CIniFile class provided on vbworld.
Look carefully at the line in red, it fills the var all with 0. I need to remove them after, how do I achieve this ?
Code:
Public Function GetFile(strSection As String, _
strKey As String) As String
Dim strTmp As String
Dim lngRet As String
strTmp = String$(100, 0)
lngRet = GetPrivateProfileString(strSection, _
strKey, "", strTmp, _
Len(strTmp), strInI)
GetFile = strTmp
End Function
-
Jul 11th, 2001, 01:57 PM
#2
That does not fill the string with 0's, it fills the string with nothing(I think it has the same effect as adding *100 after the variable declaration). If you add MsgBox strTemp after that line, you will see strTemp isn't filled with 0's.
-
Jul 11th, 2001, 03:01 PM
#3
Thread Starter
Addicted Member
ok sorry, my mistake then.
It seemed to cause a problem when splitting data afer using Split() and adding to collection. Anyway I solved the problem by making a list class CList.
Thanks for the reply !
-
Jul 11th, 2001, 06:38 PM
#4
Fanatic Member
If you're using string$(#,0), it's not filling it with nothing, it's sticking in ASCII 0, the null char. That's just not something that windows displays, and in most display things it will get turned into a space, like in the debug window. If you did want to fill it with "0", you'd give it 48 or the literal "0".
I'm baaaack...
VB5 Professional Edition, VC++ 6
Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se
I feel special because I finally figured out how to loop midis: Post link
I'm a fanatic too 
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
|